title: Does MVC OutputCaching take preference over setting cache response headers?
body: <p>This question is related to <a href="https://stackoverflow.com/questions/4078011/how-to-switch-off-caching-for-mvc-requests-but-not-for-static-files-in-iis7">my other question</a>.</p>
  
  <p>I have an MVC application with caching disabled for all controller actions. I do this by setting cache response headers in <code>Application_BeginRequest</code>:</p>
  
  <pre><code>    protected void Application_BeginRequest()
      {
          HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
          HttpContext.Current.Response.Cache.SetValidUntilExpires(false);
          HttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
          HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
          HttpContext.Current.Response.Cache.SetNoStore();
      }
  </code></pre>
  
  <p>There is single controller action for which I do want caching enabled. I have decorated this action with the <code>OutputCache</code> attribute:</p>
  
  <pre><code>[OutputCache(Duration = 300, VaryByParam = "id")]
  </code></pre>
  
  <p>What happens now for this action? Does it get cached because of the OutputCache attribute, or is it not cached because of the response headers?</p>
  
  <p><strong>-- EDIT --</strong></p>
  
  <p>As it seems, the response headers take preference. So my question becomes: how can I enable cache for single controller actions? Overwrite the response headers again?</p>