In Firebug the request header has the following entry:
Accept-Encoding: gzip, deflate
But there's no:
Content-Encoding: gzip
In the Response Header.
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.
Here's an example of my web.config settings:
<urlCompression doDynamicCompression="true" doStaticCompression="true" dynamicCompressionBeforeCache="true" />
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" minFileSizeForComp="150" staticCompressionIgnoreHitFrequency="true">
<remove name="gzip" />
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="8" dynamicCompressionLevel="8" />
</httpCompression>
I've ignored the hit frequency
staticCompressionIgnoreHitFrequency="true
"
I've confirmed that IIS is in fact compressing the files which I can see in:
C:\inetpub\temp\IIS Temporary Compressed Files
As specified here: set up gzip in IIS 8 windows 8
I've ensured that static and dynamic compression is enabled in Windows Features > Internet Information Services > WWW Services > Performance Features
I've also tried this guy's approach:
IIS 7.5 Compression creates compressed file but returns the non-compressed one
Edit 1:
IIS version is 10 but I have also tried this on IIS 8.5
Edit 2:
I've now also tried various configuration files found at this link:
https://github.com/h5bp/server-configs-iis/ which provides what looks like some 'best practice' web.config files.
Not solved
Edit 3:
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:
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
As you can see, no Content-Encoding: Gzip
Not solved
Edit 4:
I've tried this approach of adding code to the BeginRequest event in the Global.asax section: https://mcmap.net/q/282369/-how-to-enable-gzip-compression-in-iis-7-5
Not solved
Edit 5:
So I just tried enabling tracing based on this answer on SO: https://mcmap.net/q/282370/-how-do-i-enable-failed-request-tracing-in-iis-10-0-on-windows-10-development-pc
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:
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
And that's for every static type file.
However I just found the following in the trace file:
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
Compression Not Success for the reason Not Frequently Hit... Odd because I definitely have the Ignore Hit Frequency option set to true!
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:
8. STATIC_COMPRESSION_START 08:19:17.489
9. STATIC_COMPRESSION_SUCCESS 08:19:17.489
10. STATIC_COMPRESSION_END 08:19:17.489
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.
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?
Not solved
<urlCompression doDynamicCompression="true" doStaticCompression="true" dynamicCompressionBeforeCache="false" />
only. When I do test requests from a browser (Firefox, IE11, Edge, Google Chrome) to a simple MVC application. The requests all haveAccept-Encoding: gzip, deflate
and the responses returnContent-Encoding:gzip
– Hermineherminia