Created
October 8, 2013 07:57
-
-
Save gsouf/6881175 to your computer and use it in GitHub Desktop.
mod expire configuration sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Caching mod_headers + mod_expires | |
<IfModule mod_expires.c> | |
# Turn on Expires and set default to now | |
ExpiresActive On | |
ExpiresDefault "now" | |
# Set up caching on media files for 1 month | |
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|swf)$"> | |
ExpiresDefault "access plus 1 month" | |
</FilesMatch> | |
# Set up caching on images, CSS and JS files for 1 week | |
<FilesMatch "\.(gif|jpg|jpeg|png|js|css)$"> | |
ExpiresDefault "access plus 1 week" | |
</FilesMatch> | |
# Set up 1 hour caching on commonly updated files | |
<FilesMatch "\.(xml|xsl|html|htm|txt)$"> | |
ExpiresDefault "access plus 1 hour" | |
</FilesMatch> | |
# Force no caching for dynamic files | |
<FilesMatch "\.(php|cgi|pl)$"> | |
ExpiresActive Off | |
</FilesMatch> | |
</IfModule> | |
<IfModule mod_headers.c> | |
# Remote ETag from headers | |
Header unset ETag | |
# Disable ETag for files | |
FileETag None | |
# Media files are catchable | |
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|swf)$"> | |
Header append Cache-Control "public" | |
</FilesMatch> | |
# Images, css and javascript files are catchable | |
<FilesMatch "\.(gif|jpg|jpeg|png|js|css)$"> | |
Header append Cache-Control "public" | |
</FilesMatch> | |
# Commonly updated files are catchable | |
<FilesMatch "\.(xml|html|htm|txt)$"> | |
Header append Cache-Control "public" | |
</FilesMatch> | |
# Force no caching for dynamic files | |
<FilesMatch "\.(php|cgi|pl|htm)$"> | |
Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform" | |
Header set Pragma "no-cache" | |
</FilesMatch> | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment