title: Rails action caching and json responses
body: <p>I am having problems responding with JSON to json request, while having action caching enabled. </p>
  
  <p>I have a fairly simple controller which responds to both JSON and HTML and caching works fine for HTML response, but I noticed when I request JSON, and would normally respond with JSON, but with action cache enabled, it wraps the JSON output in the layout! </p>
  
  <p>When I cleared the cache, it gives me an error that no default layout exists:</p>
  
  <blockquote>
    <p>ArgumentError in ClipsController#index</p>
    
    <p>There was no default layout for ClipsController in...</p>
  </blockquote>
  
  <p>How do I return JSON for the cached action?</p>
  
  <p>UPDATE, I suspect the error about layout has to do with the way I cache the actions:</p>
  
  <p><code>caches_action :index, :layout =&gt; false</code></p>
  
  <p>I'm not sure though, why it would still need a layout in the case of a JSON response, as without caching there is no problem.</p>
  
  <p>temporarily I have modified the cache filter to not cache for JSON requests, but this is not an ideal work-around, what do I do if I do want to cache JSON?</p>
  
  <p><code>caches_action :index, :layout =&gt; false, :if =&gt; Proc.new { |c| !c.request.format.json? }</code></p>