如何清除UIWebView的缓存?
How to clear the cache of a UIWebView?
我正在制作一个简单的应用程序(只有三个按钮(后退,前进,刷新)和一个UIWebView)和我意识到在我的文件和数据iPhone获得了非常高的Cache值。我已经查看了各种文档和帖子(甚至在StackOverflow这里),但没有解决问题。 如果您需要代码行,请询问。
I am making a simple application (with only three buttons (back, forward, refresh) and a UIWebView) and I realized that in my Documents & Data iPhone gets a very high value of Cache. I already looked at various documents and posts (even here at StackOverflow) but none solved the problem. If you need lines of codes, ask.
推荐答案[[NSURLCache sharedURLCache] removeCachedResponseForRequest:NSURLRequest];
这将删除特定请求的缓存响应。还有一个调用将删除在UIWebView上运行的所有请求的所有缓存响应:
This would remove a cached response for a specific request. There is also a call that will remove all cached responses for all requests ran on the UIWebView:
[[NSURLCache sharedURLCache] removeAllCachedResponses];之后,您可以尝试使用UIWebView删除任何关联的cookie:
After that, you can try deleting any associated cookies with the UIWebView:
for(NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) { if([[cookie domain] isEqualToString:someNSStringUrlDomain]) { [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie]; } }更多推荐
UIWebView如何清除缓存
发布评论