Gerard Samuel wrote:

Searching through the archives, most people are running away from caching php scripts.
Im trying to do the opposite.
I have a script that fetches css files. Im trying to add header() calls to it so
that browsers can cache it like a normal css file.
This is what I have at the top of the file ->
----------
header('Content-type: text/css');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 3600) . ' GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime('./foo.php')) . ' GMT');
--------


For the life of me, according to the output of ethereal (a network sniffer), this file is always fetched from the server.
Yes I did breeze by the HTTP 1.1 spec, but I didn't pick up on anything special that I should be doing.


Is there a way to make the file be put into cache, or am I barking up the wrong tree.

Thanks for your insight.

Ok, I think it has been working all along.
Someone asked if I was viewing the actual headers. Yes I am, using ethereal.
During my previous tests, I was reloading the page, which caused the dynamic css file to regenerate output, while the other
css files send a "304". If I were to click on a link normally, the dynamic file doens't show up in the header stream, so Im
assuming that means its cached. Someone else suggested that I add header('Cache-Control: max-age=3600');
Ill do that as its the http 1.1 version of expire. Its not going to hurt anything.


Thanks for your pointers/comments.


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to