Java 脚本文件未进行 gzip 压缩

问题描述 投票:0回答:1

我在 IIS 上托管了我的 Angular 8 项目。

我的java脚本文件没有被gzip压缩。其他文件正在被 gzip 压缩。

我的java脚本文件

响应标题

我的 web.config -


<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
    <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
    <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"/>


我更改了 web.config 以允许 gzip

performance optimization iis gzip
1个回答
0
投票

响应头中的Content-Encoding字段显示“br”,表示该文件使用Brotli压缩算法而不是gzip压缩算法进行压缩。

虽然 Brotli 压缩具有更高的压缩比,并且已得到许多浏览器的支持,但在撰写本文时,它仍然没有像 Gzip 那样广泛采用。因此,一种可能的优化是同时启用 Brotli 和 Gzip 压缩,但如果客户端用户代理也支持,则优先考虑 Brotli。

如果您想使用gzip压缩算法而不是Brotli压缩,您需要确保在web.config文件中正确配置gzip压缩方案,并从配置中删除Brotli压缩方案。

你的 web.config 文件中没有配置 Brotli 压缩方案,但浏览器中的 Content-Encoding 字段显示“br”,那么可能是因为在其他地方配置了 Brotli 压缩,例如 IIS 或其他模块的全局配置.

相关参考链接:使用IIS压缩

© www.soinside.com 2019 - 2024. All rights reserved.