Created
November 7, 2016 21:23
-
-
Save enricodeleo/befd552372597ac4270f8cce53514b61 to your computer and use it in GitHub Desktop.
Compressing + caching with htaccess
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
# Deflate | |
<IfModule mod_filter.c> | |
#Add deflate | |
AddOutputFilterByType DEFLATE "application/atom+xml" \ | |
"application/javascript" \ | |
"application/json" \ | |
"application/ld+json" \ | |
"application/manifest+json" \ | |
"application/rdf+xml" \ | |
"application/rss+xml" \ | |
"application/schema+json" \ | |
"application/vnd.geo+json" \ | |
"application/vnd.ms-fontobject" \ | |
"application/x-font-ttf" \ | |
"application/x-javascript" \ | |
"application/x-web-app-manifest+json" \ | |
"application/xhtml+xml" \ | |
"application/xml" \ | |
"font/eot" \ | |
"font/opentype" \ | |
"image/bmp" \ | |
"image/svg+xml" \ | |
"image/vnd.microsoft.icon" \ | |
"image/x-icon" \ | |
"text/cache-manifest" \ | |
"text/css" \ | |
"text/html" \ | |
"text/javascript" \ | |
"text/plain" \ | |
"text/vcard" \ | |
"text/vnd.rim.location.xloc" \ | |
"text/vtt" \ | |
"text/x-component" \ | |
"text/x-cross-domain-policy" \ | |
"text/xml" | |
# Drop problematic browsers | |
BrowserMatch ^Mozilla/4 gzip-only-text/html | |
BrowserMatch ^Mozilla/4\.0[678] no-gzip | |
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html | |
# Make sure proxies don't deliver the wrong content | |
<IfModule mod_headers.c> | |
Header append Vary User-Agent env=!dont-vary | |
</IfModule> | |
</IfModule> | |
#add content typing | |
AddType x-font/otf .otf | |
AddType x-font/ttf .ttf | |
AddType x-font/eot .eot | |
AddType x-font/woff .woff | |
AddType image/x-icon .ico | |
AddType image/png .png | |
AddType application/x-gzip .gz .tgz | |
AddEncoding x-gzip .gz .tgz | |
# 1 Month for most static assets | |
<filesMatch ".(css|jpg|jpeg|png|gif|js|ico|svg)$"> | |
Header set Cache-Control "max-age=2592000, public" | |
</filesMatch> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment