-->

I want an auto hard refresh, not a simple auto ref

2020-07-13 08:57发布

问题:

I know I can do a simple auto-refresh on some of my webpages (for example, the Home page of my site) by inserting a meta tag like

<meta http-equiv="refresh" content="600">

But after doing this I'm getting really long page duration and session duration. This is not realistic, and I think that the refresh does not "reset" the page duration counter, which I think should happen.

I guess this could be done with a hard refresh (Ctrl-F5 in Windows, Option+R in MacOSX), but I don't know if it is possible to force the refresh to be a hard refresh... or if this kind of refresh would serve to my purpose.

回答1:

I was searching for an answer to this, and it's all in the headers apparently.

You need to send a no-cache header, in php this would be:

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past

..and then just refresh as normal (javascript or meta).



回答2:

Use this Method:

http://grizzlyweb.com/webmaster/javascripts/refresh.asp

It uses JS to the refresh and won't load the page from the browsers bf-cache so it should do what you require. It will also prevent entries from going into the users BF-cache so they will be able to use the back button correctly.