简体   繁体   中英

How to enable compression using IIS

I have followed this document and have enabled both Dynamic and Static compression for my website.

在此处输入图像描述

But when I test the website here , the compression is not enabled.

在此处输入图像描述

I have verified the HttpCompression :

<system.webServer>
  <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
    <staticTypes>
      <add mimeType="text/*" enabled="true" />
      <add mimeType="message/*" enabled="true" />
      <add mimeType="application/javascript" enabled="true" />
      <add mimeType="application/atom+xml" enabled="true" />
      <add mimeType="application/xaml+xml" enabled="true" />
      <add mimeType="image/svg+xml" enabled="true" />
      <add mimeType="*/*" enabled="false" />
    </staticTypes>
    <dynamicTypes>
      <add mimeType="text/*" enabled="true" />
      <add mimeType="message/*" enabled="true" />
      <add mimeType="application/x-javascript" enabled="true" />
      <add mimeType="application/javascript" enabled="true" />
      <add mimeType="*/*" enabled="false" />
    </dynamicTypes>
    <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
  </httpCompression>
</system.webServer>

I have also checked the following IIS Settings: 在此处输入图像描述

I see from your posted headers that the site is behind cloudfront (ie the via and x-cache headers).

Thus you may need to investigate having cloudfront provide compressed data: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html

I'm not particularly familiar with cloudfront, but since its adding the via header its acting as a proxy..

..you have noCompressionForProxies = True in your IIS settings screenshot.

This has some info on changing that setting https://community.spiceworks.com/topic/1989103-help-with-enabling-nocompressionforproxies-in-applicationhost-config-in-iis

As a 1st test you could try to hit your site by-passing cloudfront to directly test the IIS setup.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM