<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -9,7 +9,7 @@ module ActionController #:nodoc:
     #   class ListsController &lt; ApplicationController
     #     before_filter :authenticate, :except =&gt; :public
     #     caches_page   :public
-    #     caches_action :show, :feed
+    #     caches_action :index, :show, :feed
     #   end
     #
     # In this example, the public action doesn't require authentication, so it's possible to use the faster page caching method. But both the
@@ -27,15 +27,19 @@ module ActionController #:nodoc:
     # You can set modify the default action cache path by passing a :cache_path option.  This will be passed directly to ActionCachePath.path_for.  This is handy
     # for actions with multiple possible routes that should be cached differently.  If a block is given, it is called with the current controller instance.
     #
+    # And you can also use :if to pass a Proc that specifies when the action should be cached.
+    #
     #   class ListsController &lt; ApplicationController
     #     before_filter :authenticate, :except =&gt; :public
     #     caches_page   :public
+    #     caches_action :index, :if =&gt; Proc.new { |c| !c.request.format.json? } # cache if is not a JSON request
     #     caches_action :show, :cache_path =&gt; { :project =&gt; 1 }
-    #     caches_action :show, :cache_path =&gt; Proc.new { |controller| 
-    #       controller.params[:user_id] ? 
+    #     caches_action :feed, :cache_path =&gt; Proc.new { |controller|
+    #       controller.params[:user_id] ?
     #         controller.send(:user_list_url, c.params[:user_id], c.params[:id]) :
     #         controller.send(:list_url, c.params[:id]) }
     #   end
+    #
     module Actions
       def self.included(base) #:nodoc:
         base.extend(ClassMethods)
@@ -49,7 +53,8 @@ module ActionController #:nodoc:
         # See ActionController::Caching::Actions for details.
         def caches_action(*actions)
           return unless cache_configured?
-          around_filter(ActionCacheFilter.new(*actions))
+          options = actions.extract_options!
+          around_filter(ActionCacheFilter.new(:cache_path =&gt; options.delete(:cache_path)), {:only =&gt; actions}.merge(options))
         end
       end
 
@@ -67,16 +72,12 @@ module ActionController #:nodoc:
         end
 
       class ActionCacheFilter #:nodoc:
-        def initialize(*actions, &amp;block)
-          @options = actions.extract_options!
-          @actions = Set.new(actions)
+        def initialize(options, &amp;block)
+          @options = options
         end
 
         def before(controller)
-          return unless @actions.include?(controller.action_name.intern)
-
           cache_path = ActionCachePath.new(controller, path_options_for(controller, @options))
-
           if cache = controller.read_fragment(cache_path.path)
             controller.rendered_action_cache = true
             set_content_type!(controller, cache_path.extension)
@@ -88,7 +89,7 @@ module ActionController #:nodoc:
         end
 
         def after(controller)
-          return if !@actions.include?(controller.action_name.intern) || controller.rendered_action_cache || !caching_allowed(controller)
+          return if controller.rendered_action_cache || !caching_allowed(controller)
           controller.write_fragment(controller.action_cache_path.path, controller.response.body)
         end
 
@@ -105,16 +106,16 @@ module ActionController #:nodoc:
             controller.request.get? &amp;&amp; controller.response.headers['Status'].to_i == 200
           end
       end
-      
+
       class ActionCachePath
         attr_reader :path, :extension
-        
+
         class &lt;&lt; self
           def path_for(controller, options)
             new(controller, options).path
           end
         end
-        
+
         def initialize(controller, options = {})
           @extension = extract_extension(controller.request.path)
           path = controller.url_for(options).split('://').last
@@ -122,16 +123,16 @@ module ActionController #:nodoc:
           add_extension!(path, @extension)
           @path = URI.unescape(path)
         end
-        
+
         private
           def normalize!(path)
             path &lt;&lt; 'index' if path[-1] == ?/
           end
-        
+
           def add_extension!(path, extension)
             path &lt;&lt; &quot;.#{extension}&quot; if extension
           end
-          
+
           def extract_extension(file_path)
             # Don't want just what comes after the last '.' to accommodate multi part extensions
             # such as tar.gz.
@@ -140,4 +141,4 @@ module ActionController #:nodoc:
       end
     end
   end
-end
\ No newline at end of file
+end</diff>
      <filename>actionpack/lib/action_controller/caching/actions.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,7 @@ CACHE_DIR = 'test_cache'
 FILE_STORE_PATH = File.join(File.dirname(__FILE__), '/../temp/', CACHE_DIR)
 ActionController::Base.page_cache_directory = FILE_STORE_PATH
 ActionController::Base.cache_store = :file_store, FILE_STORE_PATH
+ActionController::Base.view_paths = [ File.dirname(__FILE__) + '/../fixtures/' ]
 
 class PageCachingTestController &lt; ActionController::Base
   caches_page :ok, :no_content, :if =&gt; Proc.new { |c| !c.request.format.json? }
@@ -128,7 +129,7 @@ class PageCachingTest &lt; Test::Unit::TestCase
       end
     end
   end
-  
+
   def test_page_caching_conditional_options
     @request.env['HTTP_ACCEPT'] = 'application/json'
     get :ok
@@ -151,12 +152,15 @@ end
 
 
 class ActionCachingTestController &lt; ActionController::Base
-  caches_action :index, :redirected, :forbidden
+  caches_action :index, :redirected, :forbidden, :if =&gt; Proc.new { |c| !c.request.format.json? }
   caches_action :show, :cache_path =&gt; 'http://test.host/custom/show'
   caches_action :edit, :cache_path =&gt; Proc.new { |c| c.params[:id] ? &quot;http://test.host/#{c.params[:id]};edit&quot; : &quot;http://test.host/edit&quot; }
+  caches_action :with_layout
+
+  layout 'talk_from_action.erb'
 
   def index
-    @cache_this = Time.now.to_f.to_s
+    @cache_this = MockTime.now.to_f.to_s
     render :text =&gt; @cache_this
   end
 
@@ -169,14 +173,26 @@ class ActionCachingTestController &lt; ActionController::Base
     headers[&quot;Status&quot;] = &quot;403 Forbidden&quot;
   end
 
+  def with_layout
+    @cache_this = MockTime.now.to_f.to_s
+    render :text =&gt; @cache_this, :layout =&gt; true
+  end
+
   alias_method :show, :index
   alias_method :edit, :index
+  alias_method :destroy, :index
 
   def expire
     expire_action :controller =&gt; 'action_caching_test', :action =&gt; 'index'
     render :nothing =&gt; true
   end
+end
 
+class MockTime &lt; Time
+  # Let Time spicy to assure that Time.now != Time.now
+  def to_f
+    super+rand
+  end
 end
 
 class ActionCachingMockController
@@ -223,6 +239,36 @@ class ActionCacheTest &lt; Test::Unit::TestCase
     assert_equal cached_time, @response.body
   end
 
+  def test_simple_action_not_cached
+    get :destroy
+    cached_time = content_to_cache
+    assert_equal cached_time, @response.body
+    assert_cache_does_not_exist 'hostname.com/action_caching_test/destroy'
+    reset!
+
+    get :destroy
+    assert_not_equal cached_time, @response.body
+  end
+
+  def test_action_cache_with_layout
+    get :with_layout
+    cached_time = content_to_cache
+    assert_not_equal cached_time, @response.body
+    assert_cache_exists 'hostname.com/action_caching_test/with_layout'
+    reset!
+
+    get :with_layout
+    assert_not_equal cached_time, @response.body
+
+    assert_equal @response.body, read_fragment('hostname.com/action_caching_test/with_layout')
+  end
+
+  def test_action_cache_conditional_options
+    @request.env['HTTP_ACCEPT'] = 'application/json'
+    get :index
+    assert_cache_does_not_exist 'hostname.com/action_caching_test'
+  end
+
   def test_action_cache_with_custom_cache_path
     get :show
     cached_time = content_to_cache
@@ -350,9 +396,22 @@ class ActionCacheTest &lt; Test::Unit::TestCase
     end
 
     def assert_cache_exists(path)
-      full_path = File.join(FILE_STORE_PATH, &quot;views&quot;, path + '.cache')
+      full_path = cache_path(path)
       assert File.exist?(full_path), &quot;#{full_path.inspect} does not exist.&quot;
     end
+
+    def assert_cache_does_not_exist(path)
+      full_path = cache_path(path)
+      assert !File.exist?(full_path), &quot;#{full_path.inspect} should not exist.&quot;
+    end
+
+    def cache_path(path)
+      File.join(FILE_STORE_PATH, 'views', path + '.cache')
+    end
+
+    def read_fragment(path)
+      @controller.read_fragment(path)
+    end
 end
 
 class FragmentCachingTestController &lt; ActionController::Base
@@ -516,7 +575,7 @@ class FunctionalFragmentCachingTest &lt; Test::Unit::TestCase
   def setup
     ActionController::Base.perform_caching = true
     @store = ActiveSupport::Cache::MemoryStore.new
-    ActionController::Base.cache_store = @store    
+    ActionController::Base.cache_store = @store
     @controller = FunctionalCachingController.new
     @request = ActionController::TestRequest.new
     @response = ActionController::TestResponse.new
@@ -529,17 +588,17 @@ Hello
 This bit's fragment cached
 CACHED
     assert_equal expected_body, @response.body
-    
+
     assert_equal &quot;This bit's fragment cached&quot;, @store.read('views/test.host/functional_caching/fragment_cached')
   end
-  
+
   def test_fragment_caching_in_partials
     get :html_fragment_cached_with_partial
     assert_response :success
     assert_match /Fragment caching in a partial/, @response.body
     assert_match &quot;Fragment caching in a partial&quot;, @store.read('views/test.host/functional_caching/html_fragment_cached_with_partial')
   end
-  
+
   def test_fragment_caching_in_rjs_partials
     xhr :get, :js_fragment_cached_with_partial
     assert_response :success
@@ -547,8 +606,3 @@ CACHED
     assert_match &quot;Fragment caching in a partial&quot;, @store.read('views/test.host/functional_caching/js_fragment_cached_with_partial')
   end
 end
-
-
-
-
-</diff>
      <filename>actionpack/test/controller/caching_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>bca8751e40a5594c4de2ca58e089b8d98e44632b</id>
    </parent>
  </parents>
  <author>
    <name>Joshua Peek</name>
    <email>josh@joshpeek.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/7708650f73ddb4db300ea2059c60c1d907a4384e</url>
  <id>7708650f73ddb4db300ea2059c60c1d907a4384e</id>
  <committed-date>2008-05-14T10:33:54-07:00</committed-date>
  <authored-date>2008-05-14T10:33:54-07:00</authored-date>
  <message>Added conditional support to caches_action [Jos&#233; Valim] [#166 state:resolved]</message>
  <tree>59618c18763e1d092cb9cac58cb45235819f1647</tree>
  <committer>
    <name>Joshua Peek</name>
    <email>josh@joshpeek.com</email>
  </committer>
</commit>
