Created
May 4, 2017 07:11
-
-
Save nilovelez/0543c58955dd9c5e5cb028edf470b9dc to your computer and use it in GitHub Desktop.
.htaccess GZIP + browser cache
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
# ——————————————————————— | |
# Force Cache | |
# ——————————————————————— | |
<IfModule mod_expires.c> | |
<FilesMatch "\.(jpe?g|png|gif|js|css|ico)$"> | |
ExpiresActive On | |
ExpiresDefault "access plus 1 year" | |
</FilesMatch> | |
</IfModule> | |
# ——————————————————————— | |
# Gzip compression | |
# ——————————————————————— | |
<IfModule mod_deflate.c> | |
#The following line is enough for .js and .css | |
AddOutputFilter DEFLATE js css | |
#The following line also enables compression by file content type, for the following list of Content-Type:s | |
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml | |
#The following lines are to avoid bugs with some browsers | |
BrowserMatch ^Mozilla/4 gzip-only-text/html | |
BrowserMatch ^Mozilla/4\.0[678] no-gzip | |
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html | |
</IfModule> | |
<IfModule mod_headers.c> | |
<FilesMatch "\.(js|css|xml|gz)$"> | |
Header append Vary: Accept-Encoding | |
</FilesMatch> | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment