后臺更新了URL的內(nèi)容之后,在沒有刪除app的情況下直接進行了安裝簸喂,導致出現(xiàn)了網(wǎng)頁內(nèi)容不更新的情況块差,在刪除了原來的APP侵续,重新打包之后倔丈,情況恢復(fù),懷疑是自己寫的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];