我创建了一个 web.config 文件,它成功地打开了文本和消息资源的静态压缩。但是,下面显示的明显解决方案似乎对 .svg 压缩没有任何影响(验证了 gzip 内容编码未在 .svg 文件的响应标头中设置,而是通过 chrome 开发人员工具为 .html、css 等设置) .
这是我的 web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpCompression minFileSizeForComp="1024" MaxDiskSpaceUsage="500">
<scheme name="gzip"/>
<staticTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="image/svg+xml" enabled="true"/>
<add mimeType="application/json" enabled="true" />
<add mimeType="*/*" enabled="false"/>
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true"/>
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<remove fileExtension=".svgz" />
<mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
</configuration>
这个问题的动机是按照 Google Page Speed Insights 的建议提供压缩的 SVG 字体。我一直在 IIS 7.5/Windows 7 和 IIS 8/Windows Server 2012 上测试这个 web.config。
有任何想法吗?