From 38454983b48a117737bcd25d3962e2578d6c38f0 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 24 Sep 2007 06:25:13 +0000 Subject: Cache asset ids. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7607 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/helpers/asset_tag_helper.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_view/helpers') 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 -- cgit v1.2.3