aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorRichard Hulse <richard.hulse@radionz.co.nz>2011-07-17 14:19:04 +1200
committerRichard Hulse <richard.hulse@radionz.co.nz>2011-07-17 14:19:04 +1200
commit86869a09eec2eac76e57c04b785c9b4443ad2c72 (patch)
tree128da9315ea76d13d6776b593989fc9013071edf /railties
parent0f78aeee87c25bb8fb864daf0f0a1b2bf7a241ac (diff)
downloadrails-86869a09eec2eac76e57c04b785c9b4443ad2c72.tar.gz
rails-86869a09eec2eac76e57c04b785c9b4443ad2c72.tar.bz2
rails-86869a09eec2eac76e57c04b785c9b4443ad2c72.zip
[asset pipeline] A few corrections and some new material
Add notes about capistrano task being added to that project and correction to information about precompilation.
Diffstat (limited to 'railties')
-rw-r--r--railties/guides/source/asset_pipeline.textile30
1 files changed, 25 insertions, 5 deletions
diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile
index bd7319d331..01ccabda87 100644
--- a/railties/guides/source/asset_pipeline.textile
+++ b/railties/guides/source/asset_pipeline.textile
@@ -283,24 +283,44 @@ end
If you are not precompiling your assets, and you are using the default cache file store (which is the filesystem), you will need to symlink +rails_root/tmp/cache/assets+ from the shared folder that is part of the Capistrano deployment structure. This is so the cached file persist between deployments.
-TODO: Extend above task to allow for this and add task to set it up (See commits 8f0e0b6 and 704ee0df).
+TODO: Extend above task to allow for this and add task to set it up (See commits 8f0e0b6 and 704ee0df). Note: Capistrano folks are working on a recipe - update this when it available (see https://github.com/capistrano/capistrano/pull/35).
-
-The default matcher for compiling files is rather broad:
+The default matcher for compiling files will include +application.js+, +application.css+ and all files that do not end in +js+ or +css+:
<erb>
[ /\w+\.(?!js|css).+/, /application.(css|js)$/ ]
</erb>
-In practice you may choose to narrow this to just the files that contain manifests:
+If you have other manifests or individual stylesheet and javascript files to include, you can append them to the +precompile+ array:
<erb>
-config.assets.precompile = ['application.js', 'application.css', 'admin.js', 'admin.css']
+config.assets.precompile << ['admin.js', 'admin.css', 'swfObject.js']
</erb>
+Precompiled assets exist on the filesystem and are served directly by your webserver. They do not have far-future headers by default, so to get the benefit of fingerprinting you'll have to update your server configuration to add them.
+
+For Apache:
+
+<plain>
+<LocationMatch "^/assets/.*$">
+ # Some browsers still send conditional-GET requests if there's a
+ # Last-Modified header or an ETag header even if they haven't
+ # reached the expiry date sent in the Expires header.
+ Header unset Last-Modified
+ Header unset ETag
+ FileETag None
+ # RFC says only cache for 1 year
+ ExpiresActive On
+ ExpiresDefault "access plus 1 year"
+</LocationMatch>
+</plain>
+
+TODO: NGINX instructions
+
When files are precompiled Sprockets also creates "Gzip":http://en.wikipedia.org/wiki/Gzip (.gz) version of your assets. This avoids the server having to do this for any requests; it can simply read the compressed files from disc. You must configure your server to use gzip compression and serve the compressed assets that will be stored in the public/assets folder. The following configuration options can be used:
TODO: NGINX instructions
+
TODO: Apache instructions