Search code examples
apache.htaccessbrowser-cachecache-control

.htaccess cache control max age doesn't work


I have a problem setting the cache expire date on my website. This is the code I use in .htaccess file:

<FilesMatch "\.(xml|txt|css|js)$">
    Header set Cache-Control "max-age=7200, proxy-revalidate"
</FilesMatch>

The file types I mentioned should have an expire date of 2 hours, but after hard refresh I see that all these files have an expiration date of one week. As an example, I select the .css file in Chrome inspect page and I see this information:

Accept-Ranges:bytes

Cache-Control:max-age=8000, proxy-revalidate

Connection:close

Content-Encoding:gzip

Content-Length:20229

Content-Type:text/css

Date:Wed, 26 Jul 2017 09:02:31 GMT

ETag:"1c8c1-55513528cb363-gzip"

Expires:Wed, 02 Aug 2017 09:02:31 GMT

Last-Modified:Mon, 24 Jul 2017 17:12:41 GMT

Server:Apache

Vary:Accept-Encoding

The cache control max age is working, but why is the file's expire date only one week after? Is this some kind of server cache or I am doing something wrong?


Solution

  • Just found out that cache-control:max-age always overwrites the expires tag so everything is ok.