Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

[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.
  • Loading branch information...
commit a64748bb438dcdc80ce46fa00d94ec3001bbab00 1 parent 0d30929
@rhulse rhulse authored fxn committed
Showing with 25 additions and 5 deletions.
  1. +25 −5 railties/guides/source/asset_pipeline.textile
30 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
-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+:
[ /\w+\.(?!js|css).+/, /application.(css|js)$/ ]
-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:
-config.assets.precompile = ['application.js', 'application.css', 'admin.js', 'admin.css']
+config.assets.precompile << ['admin.js', 'admin.css', 'swfObject.js']
+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:
+<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"
+TODO: NGINX instructions
When files are precompiled Sprockets also creates "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

0 comments on commit a64748b

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