title: IIS application missing Content-Encoding - gzip in Response Header
body: <p>In Firebug the request header has the following entry:<br>
  <strong>Accept-Encoding: gzip, deflate</strong>  </p>
  
  <p>But there's no:<br>
  <strong>Content-Encoding: gzip</strong><br>
  In the Response Header.  </p>
  
  <p>Regardless of anything I've tried, following a number of answers on SO and other sites, nothing seems to work!  Neither static nor dynamic files are being compressed, or at least if they are there's no content encoding - gzip value coming back in the response header. </p>
  
  <p>Here's an example of my web.config settings:  </p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;urlCompression doDynamicCompression="true" doStaticCompression="true" dynamicCompressionBeforeCache="true" /&gt;
  &lt;httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" minFileSizeForComp="150" staticCompressionIgnoreHitFrequency="true"&gt;
    &lt;remove name="gzip" /&gt;
    &lt;scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="8" dynamicCompressionLevel="8" /&gt;
  &lt;/httpCompression&gt;
  </code></pre>
  
  <p>I've ignored the hit frequency<br>
  <code>staticCompressionIgnoreHitFrequency="true</code>"</p>
  
  <p>I've confirmed that IIS is in fact compressing the files which I can see in:<br>
  <strong>C:\inetpub\temp\IIS Temporary Compressed Files</strong></p>
  
  <p>As specified here: <a href="https://stackoverflow.com/questions/16499080/set-up-gzip-in-iis-8-windows-8">set up gzip in IIS 8 windows 8</a><br>
  I've ensured that static and dynamic compression is enabled in Windows Features > Internet Information Services > WWW Services > Performance Features  </p>
  
  <p>I've also tried this guy's approach:<br>
  <a href="https://stackoverflow.com/questions/28833861/iis-7-5-compression-creates-compressed-file-but-returns-the-non-compressed-one">IIS 7.5 Compression creates compressed file but returns the non-compressed one</a>  </p>
  
  <hr>
  
  <p><strong>Edit 1:</strong><br>
  IIS version is 10 but I have also tried this on IIS 8.5</p>
  
  <hr>
  
  <p><strong>Edit 2:</strong><br>
  I've now also tried various configuration files found at this link:
  <a href="https://github.com/h5bp/server-configs-iis/" rel="nofollow noreferrer">https://github.com/h5bp/server-configs-iis/</a> which provides what looks like some 'best practice' web.config files.<br>
  <strong>Not solved</strong></p>
  
  <hr>
  
  <p><strong>Edit 3:</strong><br>
  Based on @Nkosi's input I created a completely new Asp.net MVC application and configured it using all these options I've tried. 
  Here's the raw header that I got from Fiddler:  </p>
  
  <pre><code>HTTP/1.1 200 OK
  Transfer-Encoding: chunked
  Content-Type: text/javascript; charset=UTF-8
  Expires: Wed, 20 Jul 2016 18:22:47 GMT
  Last-Modified: Wed, 20 Jul 2016 18:22:47 GMT
  Server: Microsoft-HTTPAPI/2.0
  Date: Wed, 20 Jul 2016 18:22:47 GMT
  </code></pre>
  
  <p>As you can see, no Content-Encoding: Gzip<br>
  <strong>Not solved</strong></p>
  
  <hr>
  
  <p><strong>Edit 4:</strong><br>
  I've tried this approach of adding code to the BeginRequest event in the Global.asax section: <a href="https://stackoverflow.com/a/27185575/392591">https://stackoverflow.com/a/27185575/392591</a><br>
  <strong>Not solved</strong></p>
  
  <hr>
  
  <p><strong>Edit 5:</strong><br>
  So I just tried enabling tracing based on this answer on SO: <a href="https://stackoverflow.com/a/33182525/392591">https://stackoverflow.com/a/33182525/392591</a><br>
  No failures, but I did notice right at the bottom of the trace file there's a section called GENERAL_RESPONSE_HEADERS and here's what it provides:  </p>
  
  <pre><code>Cache-Control: private
  Content-Type: text/html; charset=utf-8
  Content-Encoding: gzip
  Server: Microsoft-IIS/10.0
  X-AspNetMvc-Version: 5.2
  X-AspNet-Version: 4.0.30319
  X-Powered-By: My Little Pony
  X-UA-Compatible: IE=Edge,chrome=1
  </code></pre>
  
  <p>And that's for every static type file.<br>
  However I just found the following in the trace file:  </p>
  
  <pre><code>8. STATIC_COMPRESSION_START  08:04:03.552 
  9. STATIC_COMPRESSION_NOT_SUCCESS Reason="NOT_FREQUENTLY_HIT" 08:04:03.552 
  10. STATIC_COMPRESSION_END  08:04:03.552 
  </code></pre>
  
  <p>Compression Not Success for the reason Not Frequently Hit... Odd because I definitely have the Ignore Hit Frequency option set to true!  </p>
  
  <p>So I just went into IIS Manager and on the server I set the Ignore Hit Frequency to true (i.e. applicationHost.config) and it changed the trace file output to the following:  </p>
  
  <pre><code>8. STATIC_COMPRESSION_START  08:19:17.489 
  9. STATIC_COMPRESSION_SUCCESS  08:19:17.489 
  10. STATIC_COMPRESSION_END  08:19:17.489 
  </code></pre>
  
  <p>I went back and switched it off in the applicationHost.config and it went back to a Static Compression Not Success, so this definitely makes a difference. However, when I look at FireBug, it's still delivery the uncompressed file and no GZIP Content Encoding response header.  </p>
  
  <p>Another interesting bit I noticed in the Failed Request Trace is the final two entires GENERAL_FLUSH_RESPONSE_END and GENERAL_REQUEST_END both of which show my Bootstrap.css file as having sent 17903 bytes, roughly 18kb, matching the compressed version of the file I see in my IIS Temporary Compressed Files folder. So the file is physically being compressed and according to Failed Request traces it's sending down the right content... but then the browser picks up the full 117kb file instead?<br>
  <strong>Not solved</strong></p>
  
  <hr>