后台更新了URL的内容之后,在没有删除app的情况下直接进行了安装,导致出现了网页内容不更新的情况,在删除了原来的APP,重新打包之后,情况恢复,怀疑是自己写的webview没有添加清除缓存功能造成,下面是清除缓存的代码:
- (void)leftBarButtonAction : (UIBarButtonItem *)sender {
[self.baseButton removeFromSuperview];
_baseWebView = nil;
[self cleanCacheAndCookie];
[self.navigationController popViewControllerAnimated:YES];
}
- (void)cleanCacheAndCookie{
//清除cookies
NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies]){
[storage deleteCookie:cookie];
}
//清除UIWebView的缓存
[[NSURLCache sharedURLCache] removeAllCachedResponses];
NSURLCache * cache = [NSURLCache sharedURLCache];
[cache removeAllCachedResponses];
[cache setDiskCapacity:0];
[cache setMemoryCapacity:0];
}
或者加载的时候直接禁止缓存
request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10];
网友评论