Permalink
Browse files

Cache computed public asset paths.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7611 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 8db51ee commit 7f9a6c0d92105380a036dad2551ed952c47b2210 @jeremy jeremy committed Sep 24, 2007
Showing with 20 additions and 16 deletions.
  1. +20 −16 actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -384,27 +384,31 @@ def file_exist?(path)
# a single or wildcarded asset host, if configured, with the correct
# request protocol.
def compute_public_path(source, dir, ext = nil, include_host = true)
- source += ".#{ext}" if File.extname(source).blank? && ext
+ @@computed_public_paths ||= {}
+ @@computed_public_paths["#{@controller.request.protocol}#{@controller.request.relative_url_root}#{dir}#{source}#{ext}#{include_host}"] ||=
+ begin
+ source += ".#{ext}" if File.extname(source).blank? && ext
- if source =~ %r{^[-a-z]+://}
- source
- else
- source = "/#{dir}/#{source}" unless source[0] == ?/
- source = "#{@controller.request.relative_url_root}#{source}"
- rewrite_asset_path!(source)
+ if source =~ %r{^[-a-z]+://}
+ source
+ else
+ source = "/#{dir}/#{source}" unless source[0] == ?/
+ source = "#{@controller.request.relative_url_root}#{source}"
+ rewrite_asset_path!(source)
- if include_host
- host = compute_asset_host(source)
+ if include_host
+ host = compute_asset_host(source)
- unless host.blank? or host =~ %r{^[-a-z]+://}
- host = "#{@controller.request.protocol}#{host}"
- end
+ unless host.blank? or host =~ %r{^[-a-z]+://}
+ host = "#{@controller.request.protocol}#{host}"
+ end
- "#{host}#{source}"
- else
- source
+ "#{host}#{source}"
+ else
+ source
+ end
+ end
end
- end
end
# Pick an asset host for this source. Returns nil if no host is set,

0 comments on commit 7f9a6c0

Please sign in to comment.