Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is gzip compression not working on IIS 8.5?

I am unable to get gzip compression working on IIS 8.5 on a Server 2012 R2 machine. I have done some research and followed the instructions found in these posts:

  1. How to enable GZIP compression in IIS 7.5
  2. Compression in IIS 8.5 not successful, stating ALREADY_CONTENT_ENCODING
  3. GZip Compression On IIS 7.5 is not working
  4. gzip compression not working with IIS 8.5

Here is the relevant section of my config:

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" staticCompressionIgnoreHitFrequency="true">
    <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
    <!-- I have read that dynamic compression increases server CPU load.
    <dynamicTypes>
        <add mimeType="text/*" enabled="true"/>
        <add mimeType="message/*" enabled="true"/>
        <add mimeType="application/javascript" enabled="true"/>
        <add mimeType="*/*" enabled="false"/>
    </dynamicTypes>
    -->
    <staticTypes>
        <add mimeType="text/*" enabled="true" />
        <add mimeType="message/*" enabled="true" />
        <add mimeType="application/javascript" enabled="true" />
        <add mimeType="*/*" enabled="false" />
    </staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />

Also, in IIS, I set compression to apply to anything larger than 256 bytes. And I have performed iisreset.

Nonetheless, I don't see the compression mentioned in my dev console in Chrome or IE and PageSpeed still tells me to compress stuff. What simple step have I missed?

like image 334
mrcoulson Avatar asked Jul 21 '17 19:07

mrcoulson


People also ask

How do I enable gzip compression in IIS?

Check the httpCompression TypesCheck the httpCompression section in applicationHost. config file, you should find <add mimeType="application/x-javascript" enabled="true" /> . If this is correct, then it should be correctly configured in your IIS. This will start compressing your .

Why is gzip not working?

Older version of Gzip have a file size limit of something like 2GB. Any file larger than that will not be compressed using the Gzip algorithm. That is, however, relying on the older algorithms. Newer versions of Gzip work with larger files, though it can often take a bit of time to compress them and uncompress them.

How do you check gzip compression is enabled or not?

Double click on the file and select headers. Under 'Response headers' you are looking for the 'Connection-Encoding' field, it will say gzip if it is enabled.


2 Answers

It will be difficult to understand what is happening.Assuming that you have done all the IIS settings correct.

  • For checking if compression is working fine or not,How are you accessing the website. e.g. If you use an FQDN www.example.com ,please try and use localhost url. This will make sure your IIS settings are correct.
  • If localhost works fine and your Fully Qualified domain name does not work,then problem can be in the network.In order for compression to work,the browser needs to send request header accept-encoding:gzip, deflate . many at times your proxy or load balancer can trim this header and this header may not reach the IIS server.So IIS will never compresseven if all the settings are done right.

To verify what is happening for the request and why IIS did not compress the request,you can do the following.

  • make sure you have Failed Request tracing installed.
  • Configure your Failed Request Definition
    • Go to Failed Request tracing Modules
    • Click Add on the sidebar Failed Request tracing
    • Enable All Content and status as 200-999
    • And Finish the configuration.
    • Now reproduce the issue and you will get a traces captured in directory C:\inetpub\logs\FailedReqLogFiles\W3SVC .
    • Open the trace file(for each requests one file will be generated.Open the trace file in IE(make sure the request details matches the request you would like to verify) and go to the compact view Failed Request tracing Compact View
    • Search for Compression and also check the reason Dynamic Compression failed Reason
like image 179
Rohith Avatar answered Sep 22 '22 12:09

Rohith


As mentioned in answers to one of the questions the OP links to, be sure to check for any anti-virus software running on the server. In my case it was ESET. None of the IIS compression settings had an effect until the relevant ESET settings were disabled.

I'm leaving out details of the settings- I did what seemed like a pretty blanket disable and left it to IT to figure out which exact setting was most appropriate for compression to still work while retaining security.

like image 21
Tommy Hansen Avatar answered Sep 22 '22 12:09

Tommy Hansen