Skip to content

Instantly share code, notes, and snippets.

@tlowrimore
Last active December 14, 2015 23:59
Show Gist options
  • Save tlowrimore/5169993 to your computer and use it in GitHub Desktop.
Save tlowrimore/5169993 to your computer and use it in GitHub Desktop.
Apache config directives for serving Rails's precompiled .gz files, created by the asset pipeline during precompile.
<LocationMatch "^/assets/.*$">
Header unset ETag
FileETag None
# RFC says only cache for 1 year
ExpiresActive On
ExpiresDefault "access plus 1 year"
RewriteEngine On
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !Konqueror
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.+).(css|js)$ $1.$2.gz [QSA,L]
</LocationMatch>
<FilesMatch \.css\.gz>
ForceType text/css
</FilesMatch>
<FilesMatch \.js\.gz>
ForceType application/javascript
</FilesMatch>
AddEncoding gzip .gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment