UIWebView NSURLRequestReloadIgnoringLocalCacheData 实际上并没有忽略缓存
我有一个 UIWebView 对象,其缓存策略指定为: NSURLRequestReloadIgnoringLocalCacheData
这应该忽略本地缓存中的任何对象并从网络检索站点的最新版本。
但是,在首次加载站点后(跟踪中的十个资源,HTTP GET),站点的所有后续加载仅检索资源的一小部分(跟踪中的三个资源,HTTP GET)。这些图像似乎都是从某个本地源加载的。
我已经确认我的sharedURLCache的内存使用量为0字节,磁盘使用量为0字节。每当该过程重新启动时,都会再次检索站点的完整版本。这让我相信这些资源存储在内存缓存中,但正如我之前指出的, [[NSURLCache sharedURLCache] currentMemoryUsage] 返回 0。
我也尝试显式删除我的请求的缓存响应,但这似乎没有效果。什么给?
编辑: 此外,NSHTTPCookieStorage 在每次加载之前都会被清除,我可以确认后续加载现在检索四个资源而不是三个。无论发生什么变化,缓存问题仍然存在。
I have a UIWebView object, with the caching-policy specified as: NSURLRequestReloadIgnoringLocalCacheData
This should ignore whatever objects are in the local cache and retrieve the latest version of a site from the web.
However, after the first load of the site (ten resources in trace, HTTP GET), all subsequent loads of the site only retrieve a small subset of resources (three resources in trace, HTTP GET). The images all appear to be loaded from some local source.
I have confirmed that my sharedURLCache has a memory usage of 0 bytes, and a disk usage of 0 bytes. Whenever the process starts fresh, the full version of the site is retrieved again. This leads me to believe that these resources are being stored in an in-memory cache, but as I noted before, [[NSURLCache sharedURLCache] currentMemoryUsage] returns 0.
I have also tried explicitly removing the cached response for my request, but this seems to have no effect. What gives?
Edit:
Furthermore, the NSHTTPCookieStorage is cleared before each load, and I can confirm that the subsequent loads retrieve four resources now instead of three. The caching issue persists regardless of the change.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过将带有当前时间间隔的时间戳作为查询字符串参数附加到 URL 中,例如
我不知道这是否有效,这取决于缓存的实现方式,但可能值得一试;它有点hacky,但我很久以前在一个遥远的星系中制作Flash小程序时就使用过它。我现在遇到了同样的问题,我什至尝试使用:
UIWebView 完成加载后。
Have you tried appending a timestamp with the current time interval to the URL as a querystring parameter, e.g.
I don't know if this works, it depends on how the cache is implemented, but it might be worth giving it a try; it's a bit hacky, but I've used this a long time ago in a galaxy far far away when doing Flash applets. I'm having the same problems now, and I've even tried using:
After the UIWebView has finished loading.