I have the following PHP script (say, cache.php):
<?php
Header("Cache-Control: public");
$offset = 60 * 60 * 24 * 3;
$ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
Header($ExpStr);
echo "Hello world";
?>
To my understanding, this should make a browser to store a cached version of its output the first time it visits it, and then serve this version for the next 3 days, without even sending a request to the server. Unfortunately, this is not the case (using apache 2.2), does anyone have any helpful insight? (Obviously I can force a 304 header in the PHP script, but that shouldn’t be required)
Thanks
It appears that my fault was to check whether caching occurs by pressing F5, which (unlike for other resources like images, css etc) explicitly fetches the new entry from the server, rather than presenting the stored one. In order to check caching, one should keep a link to the page in question (on a different page) and only check whether the cached page is served by clicking on it.
As a side note, if the php page is using sessions, session.cache.limiter affects caching as well.