为什么 Safari 不遵守我的缓存控制指令?
我希望浏览器始终加载一个特定页面,特别是当用户按浏览器后退按钮访问该页面时。
因此,我在此页面的标头中使用以下“Cache-Control”指令(直接从我的代码中获取 PHP)。
$headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
这适用于 FF、IE 和 Chrome,但 Safari (5.0.1) 似乎忽略了该指令并且无法重新加载页面(跨多个用户,因此这似乎不是特定于设置的问题)。搜索没有发现任何已知的错误,所以我假设我这边出了问题。
任何指示将不胜感激。
更新:刚刚在SO上找到了这个答案。
还没有尝试过,但看起来有希望的。很奇怪,它是对 body 标签的补充,所以我持怀疑态度。
There is a particular page that I would like the browser to always load, particularly when the user presses the browser back button to get to it.
So I use the following 'Cache-Control' directive in the header for this page (taking the PHP directly from my code).
$headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
This works for FF, IE and Chrome, but Safari (5.0.1) seems to ignore the directive and fails to reload the page (across multiple users, so it doesn't seem to be a setup specific problem). Searching hasn't revealed any known bugs, so I'm assuming there is something amiss on my end.
Any pointers would be much appreciated.
Update: just found this answer on SO.
Safari browser ignoring my no-cache
Haven't tried it yet, but looks promising. Very strange that it is an addition to the body tag, so Im skeptical.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
答案是在 body 标记中包含以下属性,以强制 Safari 重新加载页面:
如:
我在这里找到了这个: Safari 浏览器忽略我的无缓存
这又从这个线程中得到它:点击后退按钮时是否有跨浏览器onload事件?
The answer is to include the following attribute in the body tag to force Safari to reload the page:
As in:
I found this here: Safari browser ignoring my no-cache
Which in turn got it from this thread: Is there a cross-browser onload event when clicking the back button?
另请参阅此 Webkit 错误报告:
https://bugs.webkit.org/show_bug.cgi?id=71509
我也遇到了同样的问题,这似乎是 Safari 中的一个错误。
Also see this Webkit bug report:
https://bugs.webkit.org/show_bug.cgi?id=71509
I am experiencing the same issue, and it appears to be to be a bug in Safari.