Forum Moderators: phranque
<?php
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
?>
[php.net...]
Now I see why the "There's more than one way to do it" comes about now.......they should have only one way in which to keep a page non-cached IMO :)
And just to confuse the "more than one way to do it" issue even more... :)
Set expiry date and cache control in Apache using mod_headers in .htaccess :
# Set http header cache expiry dates
ExpiresActive On
# Default - Expire everything 1 week from last access, declare must-revalidate
ExpiresDefault A604800
Header append Cache-Control: "must-revalidate"
# Apply a customized Cache-Control header to frequently-updated files
<Files test.html>
Header unset Cache-Control:
ExpiresDefault A0
Header append Cache-Control: "no-cache, must-revalidate"
</Files> Jim