views:

311

answers:

1

Hi,

Im trying to set up some cache control 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 about (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) doesnt make anything load from the cache at all (whereas the first technique loads everything)

Am I doing something wrong? The syntax seems to be right.

A.

+1  A: 

The syntax is correct, but the usage isn't. According to "Speed Tips: Remove Last-Modified Header" found here: http://www.askapache.com/htaccess/apache-speed-last-modified.html

If you remove the Last-Modified and ETag header, you will totally eliminate If-Modified-Since and If-None-Match requests and their 304 Not Modified Responses, so a file will stay cached without checking for updates until the Expires header indicates new content is available!

Also:

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

Refer to the original link for more details.

SolidSnakeGTI