noyearzero - 9:28 pm on Mar 16, 2011 (gmt 0)
I'm finally just now understand caching header directives. But a few things still confuse me. Firstly here is my setup...
- I parse css and js files with PHP.
- I have session.auto_start on in my httpd.conf
- I realized the session auto_start sent anti-caching headers so i turned off the auto_start for css and js files.
- I want css and js files to cache for 1 month so i do "ExpiresDefault A2592000" for them. This sends the appropriate "Expires" and "Cache-Control" headers.
- FYI: no "ETag" or "Last-Modified" headers are sent with css and js files
The first thing I notice is that according to firebug, css and js are never being pulled from the cache, a request is always sent to the server. any ideas why?
Next, I notice that my images ARE caching. They are not being parsed with PHP and they have ETag headers present. In this case a request is still sent to the server, but the server realizes the file hasn't changed and returns a "304 Not Modified" header with no file. Apache won't send an ETag header with a file parsed with php (i know they now have a directive to control this but i'm not at that apache version yet). So using PHP I sent a custom made ETag. Since it wasn't made the same way apache would, I also had to create my own test script to decide whether to send the "304 Not Modified" header. Supposing I could generate the same ETag apache would, would apache automatically return the 304 header for me?
I notice that in the REQUEST sent to the server this header is present
does that mean i'm not setting the servers response Cache-Control header correctly?
Here are the headers i'm sending in the response
HTTP/1.1 200 OK
Date: Wed, 16 Mar 2011 21:21:32 GMT
Server: Apache/2.2.8 (Win32) PHP/5.2.6
Cache-Control: max-age=2592000, public
Expires: Fri, 15 Apr 2011 21:21:32 GMT
Keep-Alive: timeout=5, max=94
Content-Type: text/css; charset=utf-8