我需要将我的 React 项目压缩为
gzip
文件,以便在生产模式下获得更好的性能。所以我用compression-webpack-plugin
压缩了我的反应文件,与下面的webpack.config
相同:
plugins: [
new CompressionPlugin({
algorithm: 'gzip',
test: /\.(js)$|\.(css)$|\.(html)$|\.eot?.+$|\.ttf?.+$|\.woff?.+$|\.svg?.+$/,
})
],
这是输出文件夹:
我正在使用 Url 重写器加载服务器上的
pre-gzip
文件,而不是 js
上的原始 web.config
文件:
<rewrite>
<outboundRules rewriteBeforeCache="true">
<rule name="Custom gzip file header">
<match serverVariable="RESPONSE_CONTENT_ENCODING" pattern=".*" />
<conditions>
<add input="{REQUEST_URI}" pattern="\.gz$" />
</conditions>
<action type="Rewrite" value="gzip"/>
</rule>
</outboundRules>
<rules>
<rule name="Rewrite gzip file">
<match url="(.*)"/>
<conditions>
<add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip" />
<add input="{REQUEST_FILENAME}.gz" matchType="IsFile" />
</conditions>
<action type="Rewrite" url="{R:1}.gz" />
</rule>
</rules>
</rewrite>
此外,我还在我的操作系统上安装了 Internet Download Manager。我的问题是互联网下载管理器,
gz
文件下载器,导致网站需要修复!这是问题的图片:
如何才能不让第三方应用程序(例如 Internet Download Manager)停留在从服务器发送的响应和想要接收它的客户端之间,并且
gzip
文件正常工作?