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.
Try setting NSURLRequest's cachePolicy to NSURLRequestReloadIgnoringLocalAndRemoteCacheData.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With