Safari为什么不遵守我的缓存控制指令? [英] Why doesn't Safari honor my cache-control directive?
问题描述
我希望浏览器始终加载一个特定的页面,特别是当用户按下浏览器的后退按钮进入该页面时。
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.
因此,我使用此页眉中的以下 Cache-Control指令(直接从我的代码中获取PHP)。
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';
此功能适用于FF,IE和Chrome,但Safari(5.0.1)似乎忽略了该指令并且无法重新加载页面(跨多个用户,因此这似乎不是特定于安装程序的问题)。搜索还没有发现任何已知的错误,因此,我认为我的观点有些不对。
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.
更新:刚刚在SO上找到了这个答案。
Update: just found this answer on SO.
还没有尝试过但是,看起来很有希望。
Haven't tried it yet, but looks promising. Very strange that it is an addition to the body tag, so Im skeptical.
推荐答案
答案是在以下代码中包含以下属性:正文标签,以强制Safari重新加载页面:
The answer is to include the following attribute in the body tag to force Safari to reload the page:
onunload=""
例如:
<body onunload="">
我在这里找到了它: Safari浏览器忽略了我的无缓存
又是从以下线程中获取的:< a href = https://stackoverflow.com/questions/158319/cross-browser-onload-event-and-the-back-button>单击后退按钮时是否存在跨浏览器加载事件?
Which in turn got it from this thread: Is there a cross-browser onload event when clicking the back button?
这篇关于Safari为什么不遵守我的缓存控制指令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!