We have a problem with JS and CSS files being cached for far too long by the browser. We do frequent development, and whenever we push out a change it breaks for some users who have the old version cached. But I can't figure out why our server is caching so hard.
I looked in our httpd.conf and we have this:
<IfModule mod_headers> <FilesMatch "\.(css|js)$"> Header set Cache-Control "max-age=43200, public, must-revalidate" </FilesMatch> </IfModule>
So, if I'm understanding this right, it should be setting JS and CSS files to cache for 12 hours - and even then check the file w/ the server to see if it has changed. But when I inspect the HTTP Response headers I get, I don't even see any Cache-Control headers! But instead of never caching these files, the browser appears to be ALWAYS caching them.
No other headers are set in our conf, and as far as I can tell we aren't even using mod_expires. This is our own server, not some hosted solution, so I have complete control over the box. We don't use .htaccess files so it's not being overridden somewhere these...
I know I'm doing something wrong here. I am pretty sure I have mod_headers installed correctly in apache, but I'm not sure how to check. Should I be using mod_expires instead or in addition? Should I be using a different max-age?
Thanks for any help you guys can provide.
After further experimentation, I've found that the headers do get sent if I comment out the
<IfModule mod_headers> statement. This is confusing, because if the module wasn't there then the resulting
Header set wouldn't work either. But sure enough it is working on my development server.
I'm nervous to deploy this as-is to our live server though. Any thoughts on why mod_headers would not be recognized by IfModule, yet still work?