Friday, April 10, 2009

mod_expires gotcha

This is for those who simply google for mod_expires and try to add those settings that you find in apache's web site and/or in other websites to your httpd.conf and wondering why some of your mime-types don't have their max-age attribute still NOT set:

for eg, you might have entries like the following in your httpd.conf for javascript but your .js files might still have not been cached by the browser (or max-age is set to zero).

ExpiresByType text/javascript "access plus 1 days"
ExpiresByType application/x-javascript "access plus 1 days"

The reason is you haven't specified the right mime-type that you have set it in your apache's mime.types file. For javascript you would've probably have:

application/javascript js

So fix your httpd.conf to use the right mime-type that is set in apache's conf/mime.types file.

By the way, with the LiveHeader plugin or Yslow plugin, FireFox is a nice and easy way to check if mod_expires (or mod_deflate for that matter) is in action.

No comments: