title: Prevent caching on ASP MVC site running on IIS 7.5
body: <p>I have an ASP MVC 3 site running on IIS 7.5 and I cant prevent it from caching.</p>
  
  <p>I have disabled the output caching in IIS by adding a '* Do Not Cache' entry to the website and also added an action filter on the controller on result execute that prevents caching too (see code below) but when I use the site, it's still caching.  I have deleted all history and cookies etc from Internet Explorer and Firefox but I still see old data.</p>
  
  <p>Does anyone have any ideas or suggestions on what else I can do to try and prevent this?</p>
  
  <p>Thanks in advance,</p>
  
  <p>James</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I have dug further using the SQL profiler and it seems to be the SQL server caching the query.  Could this be the case?</p>
  
  <p><strong>2nd UPDATE</strong></p>
  
  <p>I now know if definitley NOT SQL caching, now looking at IIS and MVC</p>
  
  <p><strong>SOLVED!!!</strong></p>
  
  <p>It was NHibernate!</p>
  
  <p>It was using the same session for every call rather than a session per request.</p>
  
  <pre><code>    public override void OnResultExecuting(ResultExecutingContext filterContext)
      {
          filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
          filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false);
          filterContext.HttpContext.Response.Cache.SetRevalidation    (HttpCacheRevalidation.AllCaches);
          filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
          filterContext.HttpContext.Response.Cache.SetNoStore();
  
          base.OnResultExecuting(filterContext);
      }
  </code></pre>