Mod_expires does not affect caching

.htaccessapache-2.2apache-2.4cache

I have mod_expires installed in Apache on CentOS VPS. It is also listed in the loaded modules, I checked by this command /usr/local/apache/bin/httpd -l

When I place the code in .htaccess, and then analyze my website with Google Page Speed or Gmetrix, they both indicate 1 hour expire for css,jpg,png files, ignoring the .htaccess code that sets 1 year for jpg,png files and 1 month for the css.

I removed the <ifmodule> from .htaccess also to double check that mod_expires is working and my site didn't respond with 500 internal server error. So it should be working!

Here is my .htaccess:

RewriteOptions inherit
RewriteEngine On
RewriteBase /
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"

Am I missing something? Any suggestions guys?

Best Answer

mod_expires doesn't override Expires headers if they're already present from whatever originally generated them (dynamic app, proxy, etc)