Skip to content
Browse files

asset pipeline guide: removes Apache config for serving pre-compresse…

…d assets, and expands the information about nginx support for this

A robust Apache configuration for this feature seems to be tricky,
one that takes into account Accept-Encoding, sets Vary, ensures
Content-Type is right, etc.
  • Loading branch information...
1 parent 7bf12a1 commit be6527f63ad89c33071d79f36e1d7583d0a764b9 @fxn fxn committed Oct 7, 2011
Showing with 12 additions and 21 deletions.
  1. +12 −21 railties/guides/source/asset_pipeline.textile
33 railties/guides/source/asset_pipeline.textile
@@ -438,36 +438,27 @@ location ~ ^/assets/ {
When files are precompiled, Sprockets also creates a "gzipped": (.gz) version of your assets. Web servers are typically configured to use a moderate compression ratio as a compromise, but since precompilation happens once Sprockets uses the maximum compression ratio, thus reducing the size of the data transfer to the minimum. One the other hand, web servers can be configured to serve compressed content directly from disk, rather than deflating non-compressed files themselves.
-A possible configuration for Apache could be:
-<LocationMatch "^/assets/.*$">
- # 2 lines to serve pre-gzipped version
- RewriteCond %{REQUEST_FILENAME}.gz -s
- RewriteRule ^(.+) $1.gz [L]
-# without these, Content-Type will be "application/x-gzip"
-<FilesMatch "^/assets/.*\.css.gz$">
- ForceType text/css
-<FilesMatch "^/assets/.*\.js.gz$">
- ForceType text/javascript
-For nginx:
+Nginx is able to do this automatically enabling +gzip_static+:
location ~ ^/(assets)/ {
root /path/to/public;
gzip_static on; # to serve pre-gzipped version
expires max;
- add_header Cache-Control public;
+ add_header Cache-Control public;
+This directive is available if the core module that provides this feature was compiled with the web server. Ubuntu packages, even +nginx-light+ have the module compiled. Otherwise, you may need to perform a manual compilation:
+./configure --with-http_gzip_static_module
+If you're compiling nginx with Phusion Passenger you'll need to pass that option when prompted.
+Unfortunately, a robust configuration for Apache is possible but tricky, please Google around.
h4. Live Compilation
In some circumstances you may wish to use live compilation. In this mode all requests for assets in the pipeline are handled by Sprockets directly.

0 comments on commit be6527f

Please sign in to comment.
Something went wrong with that request. Please try again.