Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Serving pre-gzipped assets from Apache
AddEncoding gzip .gz
RewriteEngine on
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !Konqueror
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)\.css$ $1.css.gz [QSA,L]
RewriteRule ^(.*)\.js$ $1.js.gz [QSA,L]
RewriteRule ^(.*)\.html$ $1.html.gz [QSA,L]

stepin commented Mar 2, 2013

Also you should add:
<Files *.css.gz>
ForceType text/css
<Files *.js.gz>
ForceType application/javascript
<Files *.html.gz>
ForceType text/html

or browsers will not recognize css

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment