title: ASP.NET OutPutCache VaryByParam and VaryByHeader with AJAX
body: <p>I'm trying to do some caching using VaryByParam AND VaryByHeader. When an AJAX request comes in I return a partial XHTML. When a regular request comes in I send the partial XHTML page with header / footer.</p>
  
  <p>I tried to cache the page by doing:</p>
  
  <pre><code>[OutputCache( Duration = 5, VaryByParam = "nickname,page", VaryByHeader = "X-Requested-With" )]
  </code></pre>
  
  <p>However this doesn't work... if I do a regular request first then run the AJAX call I get the full cached page instead of the partial and vice-versa. Seems like VaryByHeader is being ignored. Is it because X-Requested-With is omitted on normal requests? Or perhaps it's doing VaryByParam OR VaryByHeader?</p>
  
  <p>My obvious way around this is for AJAX requests to call a different method which only returns partial pages, however I'd like to avoid that if possible.</p>
  
  <p>I'm using ASP.NET MVC 1.0 with the <strong>OutputCacheAttribute</strong>.</p>