Htaccess 'Header unset Last-Modified' caching issue

I am trying to configure some cache management options in my htaccess file.

At the moment, it looks like this:

<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf|css|js|html|pdf)$"> Header set Cache-Control "max-age=2592000, public, must-revalidate" Header unset ETag FileETag None </FilesMatch> 

However, I read (and wanted to add) Header unset Last-Modified, so it would be something like:

 <FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf|css|js|html|pdf)$"> Header set Cache-Control "max-age=2592000, public, must-revalidate" Header unset Last-Modified Header unset ETag FileETag None </FilesMatch> 

However, using this (according to Firebug) doesn't load anything from the cache at all (whereas the first technique loads everything)

Am I doing something wrong? The syntax seems correct.

a.

+4
source share
1 answer

The syntax is correct, but use is not. According to “Speed ​​Tips: Delete Last Modified Header” found here: http://www.askapache.com/htaccess/apache-speed-last-modified.html

If you remove the Last-Modified and ETag headers, you will completely exclude If-Modified-Since and If-None-Match requests and their 304 Not Modified Responses requests, so the file will remain cached without checking for updates until the expiration header indicates that new content is available !

also:

By removing the ETag header and Last-Modified headers from your static files (images, javascript, css), browsers and caches will not be able to verify the cached version of the file compared to the real version. In addition, including the Cache-Control header and the Expires header, you can specify that certain files will be cached for a certain period of time, and you will magically (this is really a unique trick I promise) eliminate any validation requests!

See the source link for details.

+4
source

Source: https://habr.com/ru/post/1305565/


All Articles