Php by default tries as hard as it can to make the web browser not cache pages. While I can understand the rationale behind this a bit, sometimes you want caching. Caching is actually a good thing! you know. It means faster load times and lower bandwidth and processing requirements.
So I was surprised by how hard it is to turn off this aggressive non-caching policy. I googled for a few minutes and browsed the php documentation without finding an easy way of doing it. Ok, so you can use the following code snippet to enable caching in php (the argument to the function is number of seconds the page is valid):
function send_cache_headers($expire) {
header("Cache-Control: max-age=$expire");
header("Pragma: cache");
header("Expires: " . gmdate('D, d M Y H:i:s \G\M\T', time() + $expire));
}

