diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-08 05:01:35 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-06-08 05:01:35 +0000 |
commit | c9397e684c081ce7245efcfa7962f03203574f36 (patch) | |
tree | 3425732b6df033fc41fc9c27fb61f29fd2a37e69 /actionpack/lib/action_controller | |
parent | cd9d1711daaa93b8dc589f80693ee9eb7d3dfce5 (diff) | |
download | rails-c9397e684c081ce7245efcfa7962f03203574f36.tar.gz rails-c9397e684c081ce7245efcfa7962f03203574f36.tar.bz2 rails-c9397e684c081ce7245efcfa7962f03203574f36.zip |
Action caching is limited to GET requests returning 200 OK status. Closes #3335.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6970 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/caching.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb index f77cf207f5..f9f3c37c1c 100644 --- a/actionpack/lib/action_controller/caching.rb +++ b/actionpack/lib/action_controller/caching.rb @@ -240,20 +240,22 @@ module ActionController #:nodoc: end def after(controller) - return if !@actions.include?(controller.action_name.intern) || controller.rendered_action_cache + return if !@actions.include?(controller.action_name.intern) || controller.rendered_action_cache || !caching_allowed(controller) controller.write_fragment(controller.action_cache_path.path, controller.response.body) end - + private - def set_content_type!(controller, extension) controller.response.content_type = Mime::EXTENSION_LOOKUP[extension].to_s if extension end - + def path_options_for(controller, options) ((path_options = options[:cache_path]).respond_to?(:call) ? path_options.call(controller) : path_options) || {} end - + + def caching_allowed(controller) + controller.request.get? && controller.response.headers['Status'].to_i == 200 + end end class ActionCachePath |