From 5ae821a7fe97c18101908a945de2639c8a48b7a8 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 25 Nov 2007 23:24:36 +0000 Subject: Add documentation about asset timestamps (just for koz) git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8209 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/action_view/helpers/asset_tag_helper.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 47bbe2f995..441f0dea39 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -38,6 +38,27 @@ module ActionView # Note: This is purely a browser performance optimization and is not meant # for server load balancing. See http://www.die.net/musings/page_load_time/ # for background. + # + # === Using asset timestamps + # + # By default, Rails will prepend all asset paths with that asset's timestamp. This allows you to set a cache-expiration date for the + # asset far into the future, but still be able to instantly invalidate it by simply updating the file (and hence updating the timestamp, + # which then updates the URL as the timestamp is part of that, which in turn busts the cache). + # + # It's the responsibility of the web server you use to set the far-future expiration date on cache assets that you need to take + # advantage of this feature. Here's an example for Apache: + # + # # Asset Expiration + # ExpiresActive On + # + # ExpiresDefault "access plus 1 year" + # + # + # Also note that in order for this to work, all your application servers must return the same timestamps. This means that they must + # have their clocks synchronized. If one of them drift out of synch, you'll see different timestamps at random and the cache won't + # work. Which means that the browser will request the same assets over and over again even thought they didn't change. You can use + # something like Live HTTP Headers for Firefox to verify that the cache is indeed working (and that the assets are not being + # requested over and over). module AssetTagHelper ASSETS_DIR = defined?(RAILS_ROOT) ? "#{RAILS_ROOT}/public" : "public" JAVASCRIPTS_DIR = "#{ASSETS_DIR}/javascripts" -- cgit v1.2.3