For some time now, I've been trying to make Explorer cache a PHP-page. For this I've been contructing a custom header:
$mtime = filemtime(basename($_SERVER['PHP_SELF']));
$gmt_mtime = gmdate('D, d M Y H:i:s', $mtime) . ' GMT';
if ($HTTP_IF_MODIFIED_SINCE == $gmt_mtime)
{
header("HTTP/1.1 304 Not Modified");
exit;
}
$expires_header = "Expires: " . gmdate('D, d M Y H:i:s', $mtime + 3600) . ' GMT';
$lastmod_header = "Last-Modified: " . $gmt_mtime;
$etag_header = "Etag: \"tst-" . md5_f(basename($_SERVER['PHP_SELF'])) . "\"";
$cachecontrol_header = "Cache-Control: public, must-revalidate";
header($expires_header);
header($lastmod_header);
header($etag_header);
header($cachecontrol_header);
This works fine with Mozilla, which uses the cached file as long as it doesn't change.
In Explorer, on the other hand, it doesn't work. Contrairy to Mozilla, Explorer doesn't send a "If-modified-since" nor a "If-none-match" header for PHP files. (It does for other types of data).
So, something must be telling Explorer not to include those headers. And it probably is Apache with it's response headers:
HTTP/1.1 200 OK
Date: Wed, 04 Jun 2003 13:58:34 GMT
Server: Apache/1.3.26 (Unix) Debian GNU/Linux PHP/4.1.2
X-Powered-By: PHP/4.1.2
Expires: Wed, 04 Jun 2003 14:40:46 GMT
Last-Modified: Wed, 04 Jun 2003 13:40:46 GMT
Etag: "tst-6a1492b32f8d0dce4a826058fa72e837"
Cache-Control: public, must-revalidate
Keep-Alive: timeout=15, max=96
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1
Could it be the X-Powered-By header? And if so, how do I disable/remove this header without change Apache's config?
Any thoughts are welcome.
PS: for (almost 😉) all your caching needs, look at http://www.web-caching.com