Forum Moderators: phranque

Message Too Old, No Replies

Caching with htaccess

Last-modified, Cache-Control and Expires headers

         

batface

9:52 am on Jul 17, 2011 (gmt 0)

10+ Year Member



I trawled around but just don't seem to be able to get to the bottom of this one. Is it suitable to use these two together?

# cache scripts, css, and documents for 1 week, do not require revalidation
<FilesMatch "\.(js|css|pdf)$">
Header set Cache-Control: "max-age=604800"
</FilesMatch>

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css)$">
Header unset Last-Modified
</FilesMatch>
....

I note on askapache
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!


Should they be combined somehow or is there a rule for ordering of FilesMatch? Then I then dont fully understand the introduction of an expires header

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
</FilesMatch>

in terms of how to marry up the Cache-control Max-age and the Expires date?

I think i've been looking at this too long and now can't see the wood for the trees! :-)

thanks,
Mick