aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-09-24 06:25:13 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-09-24 06:25:13 +0000
commit38454983b48a117737bcd25d3962e2578d6c38f0 (patch)
treecd4accc24f7c976a46cf849c63d0f73808b8559c /actionpack/lib/action_view/helpers
parente711d8fade2a47e4a709fa3eb4b8dd7af6f6ac08 (diff)
downloadrails-38454983b48a117737bcd25d3962e2578d6c38f0.tar.gz
rails-38454983b48a117737bcd25d3962e2578d6c38f0.tar.bz2
rails-38454983b48a117737bcd25d3962e2578d6c38f0.zip
Cache asset ids.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7607 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index 9e38b4a714..4742b54eb9 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -409,9 +409,18 @@ module ActionView
# Use the RAILS_ASSET_ID environment variable or the source's
# modification time as its cache-busting asset id.
def rails_asset_id(source)
- ENV["RAILS_ASSET_ID"] ||
- File.mtime(File.join(ASSETS_DIR, source)).to_i.to_s rescue ""
+ if asset_id = ENV["RAILS_ASSET_ID"]
+ asset_id
+ else
+ @@asset_id_cache[source] ||=
+ if File.exist?(path = File.join(ASSETS_DIR, source))
+ File.mtime(path).to_i.to_s
+ else
+ ''
+ end
+ end
end
+ @@asset_id_cache = {}
# Break out the asset path rewrite so you wish to put the asset id
# someplace other than the query string.
@@ -451,4 +460,4 @@ module ActionView
end
end
end
-end \ No newline at end of file
+end