IIS application missing Content-Encoding - gzip in Response Header

前端 未结 3 997
陌清茗
陌清茗 2020-12-30 08:39

In Firebug the request header has the following entry:
Accept-Encoding: gzip, deflate

But there\'s no:
Content-Encoding: gzip

3条回答
  •  遥遥无期
    2020-12-30 09:20

    I am using IIS10 and my web.config has

    
        
        
    
    

    When I do test requests from a browser (Firefox, IE11, Edge, Google Chrome) to a simple MVC application.

    The requests all have Accept-Encoding: gzip, deflate and the responses return Content-Encoding:gzip.

    I Even tested it with Fiddler. Composing the request manually

    GET http://localhost/MyWebApplication HTTP/1.1
    User-Agent: Fiddler
    Host: localhost
    Accept-Encoding: gzip, deflate
    

    and get the same result

    HTTP/1.1 200 OK
    Cache-Control: private
    Content-Type: text/html; charset=utf-8
    Content-Encoding: gzip
    Vary: Accept-Encoding
    Server: Microsoft-IIS/10.0
    X-AspNetMvc-Version: 5.2
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET
    Date: Mon, 18 Jul 2016 15:26:06 GMT
    Content-Length: 3826
    
    ...
    

    Css, Js and all other text based files are being compressed.

    You may need to re-check your configuration to make sure you have the compression properly configured in IIS and your web.config.

    UPDATE:

    I did notice that images were not being compressed

    Request

    GET http://localhost/MyWebApplication/Images/Logo_small.png HTTP/1.1
    User-Agent: Fiddler
    Host: localhost
    Accept-Encoding: gzip, deflate
    

    Response

    HTTP/1.1 200 OK
    Cache-Control: max-age=604800
    Content-Type: image/png
    Last-Modified: Fri, 27 Nov 2015 03:15:22 GMT
    Accept-Ranges: bytes
    ETag: "c9d1fdd9c128d11:0"
    Server: Microsoft-IIS/10.0
    X-Powered-By: ASP.NET
    Date: Mon, 18 Jul 2016 15:33:02 GMT
    Content-Length: 2970
    
    ...
    

    And after some google-fu found out that the images are usually already compressed so gzip was not applied.

    FULL system.webServer from web.config

      
        
       
        
          
          
        
        
          
          
          
          
          
          
          
          
        
        
          
          
          
          
          
        
      
    

提交回复
热议问题