iOS UIWebView清除缓存

时间:2023-03-08 17:26:21

UIWebView清除Cookie:

iOS UIWebView清除缓存
//清除cookies
NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies])
{
[storage deleteCookie:cookie];
}
iOS UIWebView清除缓存

UIWebView清除缓存:

//清除UIWebView的缓存
[[NSURLCache sharedURLCache] removeAllCachedResponses]; //清除缓存(全)
NSURLCache * cache = [NSURLCache sharedURLCache];  
[cache removeAllCachedResponses];  
[cache setDiskCapacity:0];  
[cache setMemoryCapacity:0];