UIWebView中的本地HTML缓存策略 [英] Local HTML Cache policy in UIWebView

查看:193
本文介绍了UIWebView中的本地HTML缓存策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经遍历了各种解决方案,以清除UIWebView中的本地图像缓存,而我尝试以html加载图像时,它原子地显示了先前的图像(我使用相同的名称替换了模板中的图像).

I have walked through various solution to clear the local image cache in UIWebView, while i trying to load the image in html it atomically displays the previous image(i using the same name to replace the image in template).

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

这是我的代码,任何人都可以建议我这样做.提前致谢.对不起,我的英语.

this is my code and can any one please suggest me to do this. Thanks in advance. sorry for my English.

推荐答案

尝试一下...

[[NSURLCache sharedURLCache] removeCachedResponseForRequest:NSURLRequest]; 

这将删除特定请求的缓存响应.还有一个调用将删除在UIWebView上运行的所有请求的所有缓存的响应:

This would remove a cached response for a specific request. There is also a call that will remove all cached responses for all requests ran on the UIWebView:

[[NSURLCache sharedURLCache] removeAllCachedResponses];

这篇关于UIWebView中的本地HTML缓存策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆