Why doesn't Safari honor my cache-control directive?

江枫思渺然 提交于 2019-12-04 00:44:09

问题


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.


回答1:


The answer is to include the following attribute in the body tag to force Safari to reload the page:

onunload=""

As in:

<body onunload="">

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?




回答2:


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.



来源:https://stackoverflow.com/questions/3602887/why-doesnt-safari-honor-my-cache-control-directive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!