How to clear UIWebView cache?

Essentially, I need to know how to make UIWebView erase everything when you exit the application. Basically, this includes all cookies and information stored in webView through use.

Is there a way to just clean it so that it is like new every time?

+6
source share
1 answer

UIWebView does not NSURLConnection ; NSURLConnection used. Any of the following is used to work and follows the NSURLCache documentation:

 // remove all cached responses [[NSURLCache sharedURLCache] removeAllCachedResponses]; // set an empty cache NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil]; [NSURLCache setSharedURLCache:sharedCache]; // remove the cache for a particular request [[NSURLCache sharedURLCache] removeCachedResponseForRequest:request]; 

But I'm not sure now (iOS 5). Other options use a custom cache: SDURLCache or an overriding connection: withCacheResponse:. If you find out what the current behavior is, comment.

+6
source

Source: https://habr.com/ru/post/905011/


All Articles