Reputation: 2457
I am trying to configure my .htaccess file to set the cache time. Tried every possible configuration but nothing works!
This is what is written in my HTML:
<meta http-equiv="Cache-Control" content="max-age=2592000, public" />
<!-- <meta http-equiv="expires" content="mon, 24 sep 2012 14:30:00 GMT"> -->
and this is what written in my .htaccess file:
ExpiresActive On
ExpiresDefault A3600
However, when I refresh including cache clear (ctrl+F5) in firefox, my firebug NET panel says that the cache expires at the same second I have accessed the file (and not in the future, as I want it to be).
What am I doing wrong??
Thanks
Upvotes: 19
Views: 72745
Reputation: 704
I advise you to use headers mod. You can activate it (if disabled) with this command :
a2enmod headers
Here is a simple code example that works:
<IfModule mod_headers.c>
# WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# WEEK
<FilesMatch "\.(js|css|swf)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
</IfModule>
max-age is cached time in seconds.
Upvotes: 52