aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-05-19 18:59:43 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-05-19 18:59:43 +0000
commit977671c226c205c0d26e9bca65cacf05b71d545f (patch)
treebd0e004d453f7ab96b68791e47ced3a479666766
parentcaf6ff6a2f7537254b0c88f516e9b0e3347a82b3 (diff)
downloadrails-977671c226c205c0d26e9bca65cacf05b71d545f.tar.gz
rails-977671c226c205c0d26e9bca65cacf05b71d545f.tar.bz2
rails-977671c226c205c0d26e9bca65cacf05b71d545f.zip
Optimize ActionCacheFilter by using url_for less #1230 [skaen]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1326 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/lib/action_controller/caching.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb
index 7749b07815..55a4b77fda 100644
--- a/actionpack/lib/action_controller/caching.rb
+++ b/actionpack/lib/action_controller/caching.rb
@@ -180,11 +180,16 @@ module ActionController #:nodoc:
class ActionCacheFilter #:nodoc:
def initialize(*actions)
@actions = actions
+ @action_urls = {}
+ end
+
+ def action_url(controller)
+ @action_urls[controller.action_name] ||= controller.url_for.split("://").last
end
def before(controller)
return unless @actions.include?(controller.action_name.intern)
- if cache = controller.read_fragment(controller.url_for.split("://").last)
+ if cache = controller.read_fragment(action_url(controller))
controller.rendered_action_cache = true
controller.send(:render_text, cache)
false
@@ -193,7 +198,7 @@ module ActionController #:nodoc:
def after(controller)
return if !@actions.include?(controller.action_name.intern) || controller.rendered_action_cache
- controller.write_fragment(controller.url_for.split("://").last, controller.response.body)
+ controller.write_fragment(action_url(controller), controller.response.body)
end
end
end