Skip to content

Commit

Permalink
Optimize ActionCacheFilter by using url_for less #1230 [skaen]
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1326 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed May 19, 2005
1 parent caf6ff6 commit 977671c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions actionpack/lib/action_controller/caching.rb
Expand Up @@ -180,11 +180,16 @@ def expire_action(options = {})
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
Expand All @@ -193,7 +198,7 @@ def before(controller)

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
Expand Down

0 comments on commit 977671c

Please sign in to comment.