aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers
diff options
context:
space:
mode:
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