UIWebView NSURLRequestReloadIgnoringLocalCacheData 实际上并没有忽略缓存

发布于 2024-08-27 10:51:02 字数 499 浏览 8 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

×纯※雪 2024-09-03 10:51:02

您是否尝试过将带有当前时间间隔的时间戳作为查询字符串参数附加到 URL 中,例如

http://www.myhost.com/page.html?timestamp=123456789.0

我不知道这是否有效,这取决于缓存的实现方式,但可能值得一试;它有点hacky,但我很久以前在一个遥远的星系中制作Flash小程序时就使用过它。我现在遇到了同样的问题,我什至尝试使用:

[[NSURLCache sharedURLCache] removeCachedResponseForRequest: request];

UIWebView 完成加载后。

Have you tried appending a timestamp with the current time interval to the URL as a querystring parameter, e.g.

http://www.myhost.com/page.html?timestamp=123456789.0

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:

[[NSURLCache sharedURLCache] removeCachedResponseForRequest: request];

After the UIWebView has finished loading.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文