reason for action_cache before_filter?

Gustav Paul
Fri, 24 Nov 2006 11:40:11 -0000

Hey

Here''s the code for action_cache around_filters...

  def before(controller)
    return unless @actions.include?(controller.action_name.intern)
    action_cache_path = ActionCachePath.new(controller)
    if cache = controller.read_fragment(action_cache_path.path)
      controller.rendered_action_cache = true
      set_content_type!(action_cache_path)
      controller.send(:render_text, cache)
      false
    end
  end

  def after(controller)
    return if !@actions.include?(controller.action_name.intern) ||
controller.rendered_action_cache
    controller.write_fragment(ActionCachePath.path_for(controller),
controller.response.body)
  end

Why isn''t the before_filter just the first line (checking to see if the
current action need be cached), with the rest of its code in the
after_filter? I''m trying to figure out what the consequences would be
of:

  def before(controller)
    return unless @actions.include?(controller.action_name.intern)
  end

  def after(controller)
    action_cache_path = ActionCachePath.new(controller)
    if cache = controller.read_fragment(action_cache_path.path)
      controller.rendered_action_cache = true
      set_content_type!(action_cache_path)
      controller.send(:render_text, cache)
      false
    end

    return if !@actions.include?(controller.action_name.intern) ||
controller.rendered_action_cache
    controller.write_fragment(ActionCachePath.path_for(controller),
controller.response.body)
  end


Thanks in advance
Gustav Paul
gustav-PUm+PnBUKx7YkQIYctQFYw@public.gmane.org