controlling the expiration of files in the cache
I was wondering if you could help me, Im trying to set an expiration date on the caching of certain files in my website, are there some tips you could give me how to do that? Ive been able to find some things on how to change entire file types, but not SPECIFIC files. Is that possible?
ExpiresActive On # enable expirations
ExpiresByType image/gif A2592000 # expire GIF images after a month
# in the client's cache
ExpiresByType text/html M604800 # HTML documents are good for a
# week from the time they were
开发者_开发百科 # changed, period
This can help you: http://viralpatel.net/blogs/2009/06/21-very-useful-htaccess-tips-tricks.html
Check out tip #6: "Implementing a Caching Scheme with .htaccess". I think you can come up with a specific-file-based handling from here.
<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4)$"> Header set Cache-Control "public" Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT" Header unset Last-Modified </FilesMatch><FilesMatch ".(html|htm|xml|txt|xsl)$"> Header set Cache-Control "max-age=7200, must-revalidate" </FilesMatch>
<FilesMatch ".(js|css)$"> Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT" </FilesMatch>
精彩评论