-
-
Save lukemorton/829351 to your computer and use it in GitHub Desktop.
## By Luke Morton | |
# Set up caching on media files for 1 year (forever?) | |
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$"> | |
ExpiresActive On | |
ExpiresDefault A29030400 | |
Header append Cache-Control "public" | |
</FilesMatch> | |
# Force media to revalidate | |
<FilesMatch "\.(xml|txt|js|css|gif|jpe?g|png|swf)$"> | |
Header append Cache-Control "must-revalidate" | |
</FilesMatch> | |
# Force no caching for dynamic files | |
<FilesMatch "\.(php|html?)$"> | |
Header set Cache-Control "no-cache" | |
Header set Pragma "no-cache" | |
Header set Expires "-1" | |
</FilesMatch> |
## Taken From http://httpd.apache.org/docs/2.0/mod/mod_deflate.html | |
## By Luke Morton | |
# Insert filter | |
SetOutputFilter DEFLATE | |
# Don't compress images | |
SetEnvIfNoCase Request_URI \ | |
\.(?:gif|jpe?g|png)$ no-gzip dont-vary | |
# Make sure proxies don't deliver the wrong content | |
Header append Vary User-Agent env=!dont-vary |
So you're saying this is sufficient for what I wanted:
Header set Cache-Control "max-age=0"
Updated to use mod_expires (stupid IE6).
Added deflate.conf, but annoyingly I have an issue where IE6 is caching my <FilesMatch ".(php|html?)$"> unless I disable DEFLATE altogether.
Updated so now deflate.conf and cache.conf work as expected. Tested in IE6-9, Firefox 3.6, Chrome 11.
My latest changes in cache.conf
are due to the required revalidation of media files. By forcing revalidation, the image will not be pulled from the server unless it has been updated, but the browser will always check if this is the case. YSlow will complain about the lack of an expires header, but in this cache, we want the modified header to enforce when the cache should be replenished.
IMHO
no-store
is taking it too far — that's supposed to be for security-sensitive content. Also,must-revalidate
also must kill off-line usage of content.max-age=0
(andExpires
if you care about ancient clients) should be enough.CSS could be publicly cacheable.