aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2011-10-07 15:05:14 +0200
committerXavier Noria <fxn@hashref.com>2011-10-07 15:05:14 +0200
commitb1c20e37eccdfab7bb94d34f249c5e49256b9980 (patch)
treeef1494f821de54f0c32e48846b929ff9a9758590
parent3088d23647899212f20bb8969f2084393a9e71cd (diff)
downloadrails-b1c20e37eccdfab7bb94d34f249c5e49256b9980.tar.gz
rails-b1c20e37eccdfab7bb94d34f249c5e49256b9980.tar.bz2
rails-b1c20e37eccdfab7bb94d34f249c5e49256b9980.zip
asset pipeline guide: removes Apache config for serving pre-compressed 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.
-rw-r--r--railties/guides/source/asset_pipeline.textile33
1 files changed, 12 insertions, 21 deletions
diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile
index 1b06f4dedb..f2eade6bc6 100644
--- a/railties/guides/source/asset_pipeline.textile
+++ b/railties/guides/source/asset_pipeline.textile
@@ -438,36 +438,27 @@ location ~ ^/assets/ {
When files are precompiled, Sprockets also creates a "gzipped":http://en.wikipedia.org/wiki/Gzip (.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:
-
-<plain>
-<LocationMatch "^/assets/.*$">
- # 2 lines to serve pre-gzipped version
- RewriteCond %{REQUEST_FILENAME}.gz -s
- RewriteRule ^(.+) $1.gz [L]
-</LocationMatch>
-
-# without these, Content-Type will be "application/x-gzip"
-<FilesMatch "^/assets/.*\.css.gz$">
- ForceType text/css
-</FilesMatch>
-
-<FilesMatch "^/assets/.*\.js.gz$">
- ForceType text/javascript
-</FilesMatch>
-</plain>
-
-For nginx:
+Nginx is able to do this automatically enabling +gzip_static+:
<plain>
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;
}
</plain>
+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:
+
+<plain>
+./configure --with-http_gzip_static_module
+</plain>
+
+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.