UIWEBVIEW中的本地HTML缓存策略



我已经浏览了各种解决方案,以清除uiwebview中的本地图像缓存,而我尝试将图像加载到html中,它原子上显示了上一个图像(i使用相同名称替换模板中的图像)。

[[NSURLCache sharedURLCache] removeAllCachedResponses];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:[NSURL fileURLWithPath:[[CustomFunctions getFilesPath] stringByAppendingPathComponent:obj]] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30.0];
[webview1 loadRequest:request];
[webview1 reload];

这是我的代码,可以建议我这样做。提前致谢。对不起,我的英语。

//以防止应用程序中的网页内部缓存

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

尝试使用此功能。它将清除您的应用程序的URL缓存内存。

尝试这个...

[[NSURLCache sharedURLCache] removeCachedResponseForRequest:NSURLRequest]; 

这将删除用于特定请求的缓存响应。还有一个呼叫,可以删除所有请求在UIWebView上运行的所有缓存响应:

[[NSURLCache sharedURLCache] removeAllCachedResponses];

最新更新