| abstract |
 |
Here is a simple function which sends combination of headers that completely disable any browser caching.
| compatible |
 |
PHP 4.0 or higherPHP 5
<?php
function ae_nocache()
{
header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
?>
Usage example:
<?php
ae_nocache();
// disable caching
// output some highly dynamic information
// time with microseconds
list($usec, $sec) = explode(" ", microtime());
echo $sec.'.'.$usec;
?>
| tested |
 |
FreeBSD 6.2 :: PHP 5.2.1RHEL 5.0 :: PHP 4.4.5Mac OS X :: SafariMac OS X :: Firefox 2.0Windows XP :: Internet Explorer 6.0Windows Vista :: Internet Explorer 7.0