문제

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.

도움이 되었습니까?

해결책

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?

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top