aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorRichard Hulse <richard.hulse@radionz.co.nz>2011-07-16 19:02:40 +1200
committerRichard Hulse <richard.hulse@radionz.co.nz>2011-07-16 19:05:42 +1200
commit0f78aeee87c25bb8fb864daf0f0a1b2bf7a241ac (patch)
tree5752e7f486809684718173890da843c96f21754e /railties
parent765b79257a3eab2063cbf44eba6d9a405c488b0b (diff)
downloadrails-0f78aeee87c25bb8fb864daf0f0a1b2bf7a241ac.tar.gz
rails-0f78aeee87c25bb8fb864daf0f0a1b2bf7a241ac.tar.bz2
rails-0f78aeee87c25bb8fb864daf0f0a1b2bf7a241ac.zip
[asset pipeline] Add section on sendfile option
This option has caught a few people out, so it is a good idea to include an explanation and a Gotcha. See Rails bug 1822 See 1822 comment 1585926 for resolution
Diffstat (limited to 'railties')
-rw-r--r--railties/guides/source/asset_pipeline.textile14
1 files changed, 14 insertions, 0 deletions
diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile
index aca3c51db5..bd7319d331 100644
--- a/railties/guides/source/asset_pipeline.textile
+++ b/railties/guides/source/asset_pipeline.textile
@@ -367,6 +367,20 @@ config.assets.prefix = "/some_other_path"
This is a handy option if you have any existing project (pre Rails 3.1) that already uses this path.
+h4. X-Sendfile headers
+
+The X-Sendfile header is a directive to the server to ignore the response from the application, and instead serve the file specified in the headers. In production Rails (via Sprockets) does not send the asset - just the location and a zero-length response - relying on the server to do work. Files are faster served by the webserver. Both Apache and nginx support this option.
+
+New applications contain this line in +production.rb+
+
+<erb>
+config.action_dispatch.x_sendfile_header = "X-Sendfile" # Use 'X-Accel-Redirect' for nginx
+</erb>
+
+You should check that your server or hosting service actually supports this, otherwise comment it out.
+
+Gotcha: If you are upgrading an existing application and intend to use this option, take care to paste this configuration option only into +production.rb+ (and not +application.rb+ ).
+
h3. How caching works
Sprockets uses the default rails cache store to cache assets in dev and production. The only difference is filenames are fingerprinted and get far-future headers in production.