天天看点

ios webview清除缓存

UIWebView清除Cookie:

//清除cookies
NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies]) 
{
    [storage deleteCookie:cookie];
}      
UIWebView清除缓存:
      
//清除UIWebView的缓存
[[NSURLCachesharedURLCache] removeAllCachedResponses];      
By ItNoob.Matrix 链接 http://www.cnblogs.com/ItNoob
      
NSURLCache * cache = [NSURLCache sharedURLCache];
      
[cache removeAllCachedResponses];
      
[cache setDiskCapacity:0];
      
[cache setMemoryCapacity:0];