0

For security reasons, several articles recommend "do not cache pages". So I usually put the following at the beginning of my web pages

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

That works very well, but many of the users like to use the history buttons. So, I need to allow it for a short period. I tried to use the following headers

header("Cache-Control: maxage=".$expires.", must-revalidate");
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');

where $expires is the time I need. The problem is that pages do not expire, as if those headers were not there. How can I solve this?

Thank you in advance

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by jmichae3
0

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

see this page for reference on cache-control. it has a BNF grammar. apparently $expires must be in delta-seconds.

you can try adding public to cache-control and see what happens.

also keep in mind that the server may not necessarily have the proper time and date. one can hope.
I only base this on my experience with filezilla and uploading files to the server and noting the file's timestamp difference between my machine and the server's, even though I have "sync timestamps" turned on.

that doesn't seem to be a problem with my hosting company now.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.