title: ASP.NET MVC - Cache & Compression settings in web.config not always being used
body: <p>In my ASP.NET MVC 2 application I've decorated an action with the following attributes.</p>
  
  <pre><code>[ETag]
  [OutputCache(Duration = 604800, VaryByParam = "none", Location = OutputCacheLocation.Any)]
  public ActionResult Index()
  </code></pre>
  
  <p>(for the ETag attribute I've used the attribute class found <a href="https://stackoverflow.com/questions/6642815/create-etag-filler-in-asp-net-mvc">here</a>.)</p>
  
  <p>I've also added the following to my web.config.</p>
  
  <pre><code>&lt;!-- gzip compression --&gt;
  &lt;httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files"&gt;
    &lt;scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="9" /&gt;
    &lt;dynamicTypes&gt;
      &lt;add mimeType="text/*" enabled="true" /&gt;
      &lt;add mimeType="message/*" enabled="true" /&gt;
      &lt;add mimeType="application/x-javascript" enabled="true" /&gt;
      &lt;add mimeType="application/json" enabled="true" /&gt;
      &lt;add mimeType="*/*" enabled="false" /&gt;
    &lt;/dynamicTypes&gt;
    &lt;staticTypes&gt;
      &lt;add mimeType="text/*" enabled="true" /&gt;
      &lt;add mimeType="message/*" enabled="true" /&gt;
      &lt;add mimeType="application/x-javascript" enabled="true" /&gt;
      &lt;add mimeType="application/atom+xml" enabled="true" /&gt;
      &lt;add mimeType="application/xaml+xml" enabled="true" /&gt;
      &lt;add mimeType="*/*" enabled="false" /&gt;
    &lt;/staticTypes&gt;
  &lt;/httpCompression&gt;
  &lt;urlCompression doStaticCompression="true" doDynamicCompression="true" /&gt;
  
  &lt;!-- ETags --&gt;
  &lt;httpProtocol&gt;
    &lt;customHeaders&gt;
      &lt;add name="ETag" value="&amp;quot;&amp;quot;" /&gt;
    &lt;/customHeaders&gt;
  &lt;/httpProtocol&gt;
  
  &lt;!-- Expiry --&gt;
  &lt;staticContent&gt;
    &lt;clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" /&gt;
  &lt;/staticContent&gt;
  </code></pre>
  
  <p>My problem is that when I load the page from my hosting server and view the header in Firebug I receieve an ETag, but no cache expiry.</p>
  
  <pre><code>Cache-Control   private
  Content-Type    text/html; charset=utf-8
  Etag    HKQ9Pp6hFTMRZYZbbIi3HA==,""
  Server  Microsoft-IIS/7.0
  X-AspNetMvc-Version 2.0
  X-AspNet-Version    4.0.30319
  X-Powered-By    ASP.NET
  Date    Tue, 06 Sep 2011 18:31:05 GMT
  Content-Length  4447
  </code></pre>
  
  <p>When I load the page locally the response <em>does not</em> have an ETag, but <em>does</em> have "Cache-Control" and "Expires" fields set.</p>
  
  <pre><code>Server  ASP.NET Development Server/10.0.0.0
  Date    Tue, 06 Sep 2011 18:33:55 GMT
  X-AspNet-Version    4.0.30319
  X-AspNetMvc-Version 2.0
  Cache-Control   private, max-age=604800
  Expires Tue, 13 Sep 2011 18:33:54 GMT
  Last-Modified   Tue, 06 Sep 2011 18:33:54 GMT
  Content-Type    text/html; charset=utf-8
  Content-Length  4447
  Connection  Close
  </code></pre>
  
  <p>Also, note that although I'm setting gzip compression in the web.config, it doesn't appear in <em>either</em> of the response headers.</p>
  
  <p>So why do the settings in my web.config file appear to be ignored part of the time? Is it possible that my hosting server overrides these? If so, it doesn't make much sense for them to <em>remove</em> the cache or compression settings, does it?</p>