I am trying to set an intelligent cache using PHP. I have used:
$seconds_to_cache = 300; //5 minutes
$ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
header("Expires: $ts");
header("Pragma: cache");
header("Cache-Control: max-age=$seconds_to_cache");
I have tried it before and after session_start(). The timer only works the first time I load the page. After that it simply refreshes all the content each time without waiting 5 minutes.
How do I make this work?