Created
December 30, 2011 06:57
-
-
Save michsch/1538366 to your computer and use it in GitHub Desktop.
.htaccess compression and caching
This file contains hidden or 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
# BEGIN Compress text files | |
<IfModule mod_deflate.c> | |
<FilesMatch "\.(x?html?|php|js|css)$"> | |
SetOutputFilter DEFLATE | |
</FilesMatch> | |
</IfModule> | |
# END Compress text files | |
# Expires Header + Removal of ETag | |
<FilesMatch "\.(ico|png|gif|js|css|jpg|jpeg|swf)"> | |
<IfModule mod_expires.c> | |
ExpiresActive on | |
ExpiresDefault "access plus 6 month" | |
</IfModule> | |
# ETag | |
FileETag MTime Size | |
<IfModule mod_headers.c> | |
FileETag none | |
Header unset Last-Modified | |
</IfModule> | |
</FilesMatch> | |
# BEGIN Cache-Control Headers | |
<IfModule mod_headers.c> | |
<FilesMatch "\\.(ico|jpe?g|png|gif|swf)$"> | |
Header set Cache-Control "max-age=2592000, public" | |
</FilesMatch> | |
<FilesMatch "\\.(css)$"> | |
Header set Cache-Control "max-age=604800, public" | |
</FilesMatch> | |
<FilesMatch "\\.(js)$"> | |
Header set Cache-Control "max-age=216000, private" | |
</FilesMatch> | |
<FilesMatch "\\.(x?html?|php)$"> | |
Header set Cache-Control "max-age=600, private, must-revalidate" | |
</FilesMatch> | |
</IfModule> | |
# END Cache-Control Headers | |
# BEGIN Turn ETags Off | |
<IfModule mod_headers.c> | |
Header unset ETag | |
</IfModule> | |
FileETag None | |
# END Turn ETags Off | |
# BEGIN Remove Last-Modified Header | |
<IfModule mod_headers.c> | |
Header unset Last-Modified | |
</IfModule> | |
# END Remove Last-Modified Header | |
# Compressed Content | |
<FilesMatch "(\.gz\.(js|css))|\.(js|css)\.gz"> | |
<IfModule mod_headers.c> | |
Header set Content-Encoding gzip | |
</IfModule> | |
</FilesMatch> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment