title: How to disable server-side caching on IIS 7.5 (asp net mvc3)
body: <p>I'm struggling with my IIS setup regarding caching, here's a brief description of my problem:</p>
  
  <p>I'm making a site for mobile and non-mobile, sharing the same controllers. IE: mysite/page will serve either mysite/page.cshtml, or mysite/M/page.cshtml, depending on the device.</p>
  
  <p>Here's the catch, it worked fine with my local and integration environment (cassiini and iis 6), but on another machine (2008r2/iis 7.5), apparently there is an aggressive <em>server-side</em> caching policy:</p>
  
  <ul>
  <li>If I access the website from a desktop machine, I have the correct pages (desktop version)</li>
  <li>If now I use my mobile phone to access the site, I will have the desktop version, (which implies a server-side cache, my phone is not using the same network).</li>
  </ul>
  
  <p>On the contrary, if I were to restart the server and access the site using my phone first, then I will get the mobile version on my desktop (only for the pages I already visited of course).</p>
  
  <p>I tried 2 solutions so far:</p>
  
  <p>Disabling OutputCache from my Web.config:</p>
  
  <pre><code>&lt;httpModules&gt;
    [..]
    &lt;remove name="OutputCache" /&gt;
  &lt;/httpModules&gt;
  </code></pre>
  
  <p>And unchecking "Enable output cache" in "Output Caching" for my site in IIS.</p>
  
  <p>What's bugging me is that I do not have this problem with my other server (iis 6.0), although caching is enabled on this one, which leads me to think it is related to iis 7 caching addition.</p>
  
  <p>My question is simple: <strong>how does one disable server-side caching on IIS 7.5?</strong></p>
  
  <p>Thanks in advance for your iis lights!</p>
  
  <h1>Found it!</h1>
  
  <p>Sorry guys you could not really guess that one, I extend RazorViewEngine (actually I used a sample mobile mvc3 template app), and this class overrides FindView, it is supposed to take into account a useCache parameter, but apparently no matter how I configure IIS, it was set to true with iis7. I set it to false everywhere. I'll look into appropriate tuning of that parameter tomorrow.</p>
  
  <pre><code>public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
  </code></pre>
  
  <p>Thanks for your help guys, I have a good understanding of all the caching possibilities with IIS now ;). It's interesting that this behaves differently with IIS 7.0 (IIS6 and Cassiini were consistent).</p>
  
  <p>Edit:</p>
  
  <p>More info: <a href="http://aspnet.codeplex.com/workitem/8201?PendingVoteId=8201" rel="nofollow">http://aspnet.codeplex.com/workitem/8201?PendingVoteId=8201</a> , it is related to debug/release working of FindView.</p>
  
  <p>This was my exact problem: <a href="http://aspnet.codeplex.com/workitem/8201?PendingVoteId=8201" rel="nofollow">http://aspnet.codeplex.com/workitem/8201?PendingVoteId=8201</a></p>