On 02 août 2004, Sir
jo******@fastermail.com (John) claimed in
news:1a**************************@posting.google.c om:
I have read somewhere else in this newsgroup that the way to avoid the
message (Warning: Page has Expired blah, blah blah ... ) when one
presses the back button is to place the statement
header("Cache-Control: public");
at the top of the script.
I have done this but I still get the annoying message.
The session.cache_expire in php.ini is set to 180. I am using shared
SSL.
Thank you for you help
John
Well that's not true, you need to tell the browser that it can cache the
page so, you have to tell him that the page is valid for a certain time,
the header("Cache-Control: public"); just tell to intermediate proxies
that they are authorized to record the page in their cache.
what you need is to send headers like:
header("Cache-Control: private, max-age=3600");
##tell that it can keep the page for 1 hour in his cache (may be enough
to avoid the "page expire thing")
header("Expires: Wed, 04 Aug 2004 12:28:41 GMT");
##tell that he must check the page validity after this date
header("Last-Modified: Fri, 16 Jul 2004 22:07:59 GMT");
##tell that the page was modified on this date (used by proxies and
browsers to know if they need to recache the page or not)
so youre code would be:
<?php
$valid_date=3600;
$the_time=time();
$lastmodifie=filemtime(_SERVER["SCRIPT_FILENAME"]);
header("Cache-Control: private, max-age=$valid_date");
header("Expires: " . gmdate("D, d M Y H:i:s", $the_time + $valid_date) .
" GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodifie) . "
GMT");
?>