0
@@ -40,6 +40,8 @@ module ActionController #:nodoc:
0
# controller.send(:list_url, c.params[:id]) }
0
+ # If you pass :layout => false, it will only cache your action content. It is useful when your layout has dynamic information.
0
def self.included(base) #:nodoc:
0
base.extend(ClassMethods)
0
@@ -54,7 +56,8 @@ module ActionController #:nodoc:
0
def caches_action(*actions)
0
return unless cache_configured?
0
options = actions.extract_options!
0
- around_filter(ActionCacheFilter.new(:cache_path => options.delete(:cache_path)), {:only => actions}.merge(options))
0
+ cache_filter = ActionCacheFilter.new(:layout => options.delete(:layout), :cache_path => options.delete(:cache_path))
0
+ around_filter(cache_filter, {:only => actions}.merge(options))
0
@@ -81,7 +84,9 @@ module ActionController #:nodoc:
0
if cache = controller.read_fragment(cache_path.path)
0
controller.rendered_action_cache = true
0
set_content_type!(controller, cache_path.extension)
0
- controller.send!(:render_for_text, cache)
0
+ options = { :text => cache }
0
+ options.merge!(:layout => true) if cache_layout?
0
+ controller.send!(:render, options)
0
controller.action_cache_path = cache_path
0
@@ -90,7 +95,8 @@ module ActionController #:nodoc:
0
return if controller.rendered_action_cache || !caching_allowed(controller)
0
- controller.write_fragment(controller.action_cache_path.path, controller.response.body)
0
+ action_content = cache_layout? ? content_for_layout(controller) : controller.response.body
0
+ controller.write_fragment(controller.action_cache_path.path, action_content)
0
@@ -105,6 +111,14 @@ module ActionController #:nodoc:
0
def caching_allowed(controller)
0
controller.request.get? && controller.response.headers['Status'].to_i == 200
0
+ @options[:layout] == false
0
+ def content_for_layout(controller)
0
+ controller.response.layout && controller.response.template.instance_variable_get('@content_for_layout')