diff options
author | Tim Lowrimore <tlowrimore@coroutine.com> | 2013-03-15 12:36:16 -0500 |
---|---|---|
committer | Tim Lowrimore <tlowrimore@coroutine.com> | 2013-03-15 12:36:16 -0500 |
commit | aec466e75294be177f66472fcdbd392831b26fdd (patch) | |
tree | 45bdbf5cd6f6c766b880ee8da9261a96d81b2ca1 /guides | |
parent | 6e0aafbba2300e78ecb8bf956dd5e90b6acf6b94 (diff) | |
download | rails-aec466e75294be177f66472fcdbd392831b26fdd.tar.gz rails-aec466e75294be177f66472fcdbd392831b26fdd.tar.bz2 rails-aec466e75294be177f66472fcdbd392831b26fdd.zip |
added details to section 4.1.2 of the Asset Pipeline guide, describing how to configure Apache to serve the gzipped version of the precompiled assets
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/asset_pipeline.md | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md index e939606c88..aa0e0a3042 100644 --- a/guides/source/asset_pipeline.md +++ b/guides/source/asset_pipeline.md @@ -547,7 +547,35 @@ This directive is available if the core module that provides this feature was co If you're compiling nginx with Phusion Passenger you'll need to pass that option when prompted. -A robust configuration for Apache is possible but tricky; please Google around. (Or help update this Guide if you have a good example configuration for Apache.) +Apache is also able to serve the [gzipped](http://en.wikipedia.org/wiki/Gzip) version of your assets; however, it requires a bit more work: + +```apache +<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 +``` + +NOTE: You will need to make sure `mod_headers`, `mod_mime` and `mod_rewrite` are loaded; otherwise, the above configuration will fail. ### Local Precompilation |