我创建了一个web.config文件,成功地开启了文本和消息资源的静态压缩。 然而,下面显示的明显解决方案对.svg压缩似乎没有任何影响(通过chrome开发人员工具验证,.svg文件的响应头中未设置gzip内容编码,但对于.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上进行了测试。
有任何想法吗?