title: How to clear the cache for all the pages when we use pagination
body: <p>We use dalli gem w/memcached. The following code caches Foo objects paginated across multiple pages. We are able to cache Foo(s) when we are in a certain page (say 2 or 10 or 15). But when I modify a Foo in page 15 (say Foo-150), we clear the cache for all the objects using the method in FooSweeper. after_save method is being called when the above
   action happens, but the cache is not getting cleared for all pages and reflects the older values for the requested page.</p>
  
  <p>Is there any mistake in the code snippet given below.</p>
  
  <p>My controller looks like this..</p>
  
  <pre><code>class FooController 
  
  ...
    caches_action :index, cache_path: proc { |c| c.params.except(:_).merge(format: request.format) }
  
  ...
  </code></pre>
  
  <p>My sweeper code looks like this..</p>
  
  <pre><code>class FooSweeper &lt; ActionController::Caching::Sweeper
    observe :foo
  
    def after_save(foo)
      expire_cache(foo)
    end
  
    def before_destroy(foo)
      expire_cache(foo)
    end
  
    def expire_cache(foo)
      expire_action(:controller =&gt; 'foos', :action =&gt; 'index')
      expire_action(:controller =&gt; 'foos', :action =&gt; 'index', :format =&gt; 'text/html')
    end
  end
  </code></pre>