0
votes

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?

1
Do you have AllowOveride enabled? Without it, Apache will not process .htaccess.Cyril Graze
Yes, it is enabled. Also as I understand the max-age is working, because I see that value in the file properties window, but somehow "Expires" field overrides the cache expire date.The50
Have you checked your *.conf files in the /etc/apache folder, and other .htaccess files higher up the directory hierarchy for possible overridden cache values?Cyril Graze
There is no other .htaccess files. I don't know about the .conf files, have to check with the server provider, will do that soon. Thanks for the tips.The50

1 Answers

0
votes

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