note 8653 deleted from function.header by jimw
| From: | jimw@php.net | Date: | Wed, 31 Oct 2001 21:43:44 +0000 |
| Subject: | note 8653 deleted from function.header by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-19744@lists.php.net to get a copy of this message | ||
Speaking of cacheability, allowing your basic php documents to be cached for a short period is often
a very good idea. For example, I have php files that simply interpret text files. They always give
the same output, so they may as well be long-term cacheable. How to do this easily? I wrote a
quick function called CacheControl (consider it under the GPL) based on information available at: http://www.mnot.net/cache_docs/
("How to make your documents work with web caches").
function CacheControl($maxage, $smaxage)
{
$Modified = "Last-modified: ".gmdate("D, d M Y H:i:s", time())."
GMT";
$Expires = "Expires: ".gmdate("D, d M Y H:i:s", time() +
$maxage)." GMT";
$CacheControl = "Cache-Control: must-revalidate, max-age=".$maxage.", ";
$CacheControl.= "s-max-age=".$smaxage;
Header($CacheControl);
Header($Modified);
Header($Expires);
}