I have my javascript in a PHP file with the following code at the top of the file. The idea is to make the browser cache the javascript and gzip it so that it won’t get downloaded one very page view, but when checking the Web Inspector, it is returning 200 instead of 304 and appears to be re-downloaiding the file on every page view.
<?php
@ob_start ("ob_gzhandler");
header("Last-Modified: Mon, 05 Nov 2010 01:00:00 GMT");
header("Expires: ".gmdate("D, d M Y H:i:s", time()+2592000)." GMT");
header("Cache-Control: max-age=2592000");
header("ETag: \"9097158e797a93a8e213c6c5c72a2a7c\"");
header("Content-type: application/x-javascript; charset=utf-8;");
?>
most likely your webserver rewrites the headers based on its configuration.
php file are usually danymic and shouldnt be cached.
dunno if you use mod_headers, mod_expires or whatever, but the cleanest idea would probably be not to print any headers in your scripts but to handle the caching headers by webserver configuration which you define in your folder for static files. maby by htaccess or something.