Remove Uiwebview's Internal Cache

Clearing Caches from safari in iOS

it's weird that neither [[NSURLCache sharedURLCache] removeAllCachedResponses]; nor [[NSURLCache sharedURLCache] removeAllCachedResponses]; works for you.

you may try one more (although not nice) trick:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if(request.cachePolicy != NSURLRequestReloadIgnoringLocalCacheData) {
NSURLRequst* noCacheRequest = [[NSURLRequest alloc] initWithURL:request.URL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:request.timeoutInterval];
[webView loadRequest:noCacheRequest];
return false;
}
else
return true;
}

also, try setHTTPShouldHandleCookies:, like here

Clear NSURLConnection cache

You can clear the cache explicitly using:

obj-c

[[NSURLCache sharedURLCache] removeAllCachedResponses];

swift

 URLCache.shared.removeAllCachedResponses()


Related Topics



Leave a reply



Submit