Reputation: 4533
I have an external folder with html files and JS files. I have a problem to make my webView to work with updated version of this folder. I mean if I change JS file it doesn't takes the updated version and works always with the old version. How do I prevent this "caching"? I'm running the application from Xcode and even after I exit Xcode and relaunch the application it works with old version.
Thanks for help
Upvotes: 2
Views: 1556
Reputation: 4533
This code is supposed to disable caching on WebKit:
[[WebPreferences standardPreferences] setCacheModel:WebCacheModelDocumentViewer];
[[WebPreferences standardPreferences] setUsesPageCache:NO];
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];
[sharedCache release];
sharedCache = nil;
It helped me anyway
Upvotes: 2
Reputation: 187064
If you never want caching, append the current timestamp the end of the url of your assets.
"myJsFile.js?12378127389"
This makes the url different every time an causes the cache check to miss, which means it will reload it from disk.
Upvotes: 1