如何清除ipad中的webviewcaching

这里我已经使用uiwebview加载了内容

[webView loadHTMLString:[theApp.contentArr objectAtIndex:spineIndex] baseURL:url]; 

回去后,我需要清除caching

在这里我已经尝试了这些方法来清除caching:

  [webView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML = \"\";"]; [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]]; // remove all cached responses [[NSURLCache sharedURLCache] removeAllCachedResponses]; // set an empty cache NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil]; [NSURLCache setSharedURLCache:sharedCache]; 

但没有用,这是什么解决scheme…..

简单的方法 :

 NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil]; [NSURLCache setSharedURLCache:sharedCache]; 

使用 –

 [webView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML = \"\";"]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]; [urlRequest setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; [webView loadRequest:urlRequest];