Reputation: 598
I have a web view that loads a url on request. However, when this web view reloads the same url, the content does not get updated, but remains as it was after it was first loaded. I'm assuming this is due to automatic caching? Deleting the apps documents and data allows the webview to be refreshed, but then the issue occurs again.
Upvotes: 5
Views: 2933
Reputation: 1985
From NSURLRequest.h iOS 8.0
typedef NS_ENUM(NSUInteger, NSURLRequestCachePolicy)
{
NSURLRequestUseProtocolCachePolicy = 0,
NSURLRequestReloadIgnoringLocalCacheData = 1,
NSURLRequestReloadIgnoringLocalAndRemoteCacheData = 4, // Unimplemented
NSURLRequestReloadIgnoringCacheData = NSURLRequestReloadIgnoringLocalCacheData,
NSURLRequestReturnCacheDataElseLoad = 2,
NSURLRequestReturnCacheDataDontLoad = 3,
NSURLRequestReloadRevalidatingCacheData = 5, // Unimplemented
};
you should be using NSURLRequestReloadIgnoringCacheData. I had the same problem. I relied on autocomplete and used the unimplemented methods.
Upvotes: 1
Reputation: 1096
Try setting NSURLRequest's cachePolicy to NSURLRequestReloadIgnoringLocalAndRemoteCacheData.
Upvotes: 4