title: Rails fragment caching strategy
body: <p>I've got a site i'm implementing some caching into. </p>
  
  <p>Where possible, i have used action caching and i have sweepers in place to expire the necessary actions when models are created/updated.</p>
  
  <p>Within the views that are subject to <code>caches_action</code> i have also fragment cached some partials so that within the partial i have something like:</p>
  
  <pre><code>&lt;% cache('video_content') do %&gt;
     Some content here
  &lt;% end %&gt;
  </code></pre>
  
  <p>In my <code>video_sweeper</code> i am trying to expire this fragment with:</p>
  
  <pre><code>expire_fragment('video_content')
  </code></pre>
  
  <p>This fragment isn't expiring though. </p>
  
  <p>Because i am using <code>caches_action</code> already, is the fragment being ignored for some reason? i.e do i need to make a choice between using <code>caches_action</code> or fragment caching?</p>
  
  <p>If this is the case, i would need to expire every action view this partial appears in which means my sweepers are going to get hellishly complicated, let alone the maintenance headache.</p>
  
  <p>So my question is largely, why won't my fragment cache expire when called from my sweeper and is it because i am using <code>caches_action</code> too?</p>
  
  <p><strong>Update:</strong>
  Further digging into my logs i can actually see that the sweeper is expiring my fragment.</p>
  
  <pre><code>Expire fragment views/video_content (0.7ms)
  </code></pre>
  
  <p>However, playing around in the console prior to the expiration, the fragment doesn't seem to exist.</p>
  
  <pre><code>ruby-1.9.2-p136 :004 &gt; Rails.cache.exist?('views/video_content')
   =&gt; false
  </code></pre>
  
  <p>Again, this makes me think that because i am using <code>caches_action</code> that the partial will rarely be hit, except when the action is expired, to be cached.</p>