gzip compression not working with IIS 8.5

2019-07-10 06:13发布

问题:

I have a Server 2012 R2 box running IIS. I've tried enabling compression for several sites running on that box, but I can't figure out why it won't work. My request headers all show accept-encoding, but the response headers are always Transfer-Encoding:chunked and Vary:Accept-Encoding. The following steps have been performed to try to get gzip compression working:

  1. Dynamic and Static compression have been enabled on each site and at the machine level
  2. Both compression methods are installed from Server Manager
  3. Httpcompression and urlcompression nodes have been manually added to web.configs
  4. Mime types are defined for compression
  5. frequentHitThreshold has been set to 1, so all content should be compressed after the first attempt to access it

A trace has been done to see why compression isn't occurring. The only information I have is the code DYNAMIC_COMPRESSION_NOT_SUCCESS with a reason of 1.

Here are the headers:

GET http://redactedservername:8082/ HTTP/1.1  
Host: redactedservername:8082  
Connection: keep-alive  
Cache-Control: max-age=0  
Accept:   text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8  
Upgrade-Insecure-Requests: 1  
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36  
DNT: 1  
Accept-Encoding: gzip, deflate, sdch  
Accept-Language: en-US,en;q=0.8  
Cookie: ASP.NET_SessionId=gnqovt55ggt22lycufudc0ns  

`

HTTP/1.1 200 OK  
Cache-Control: private  
Content-Type: text/html; charset=utf-8  
Vary: Accept-Encoding  
Date: Wed, 22 Jun 2016 14:00:57 GMT  
Transfer-Encoding: chunked

What other steps can be performed to get compression to work?

回答1:

Compression was working, but ESET Antivirus was doing its job of monitoring web traffic. This modified the response and I didn't get gzip content encoding as expected. Disabling ESET and testing again showed that compression was functioning.