I have created a web.config file that successfully turns on static compression for text and message resources. However, the obvious solution shown below does not seem to have any affect on .svg compression (validated that gzip content encoding not set in response header for .svg files, but is set for .html, css, etc. via chrome developer tools).
Here is my 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>
The motivation for this question is to deliver compressed SVG fonts as recommended by Google Page Speed Insights. I've been testing this web.config on IIS 7.5/Windows 7 and IIS 8/Windows Server 2012.
Any ideas?
Check the httpCompression TypesCheck the httpCompression section in applicationHost. config file, you should find <add mimeType="application/x-javascript" enabled="true" /> . If this is correct, then it should be correctly configured in your IIS. This will start compressing your .
SVG file compress software can compress your SVG image files, allowing you to easily transmit and store your data.
You can tell using Developer Tools (F12). Go to the Network tab, select the file you want to examine and then look at the Headers tab on the right. If you are gzipped, then you will see that in the Content-Encoding.
IIS will not gzip too small files, and you can config the minium size. In IIS 7.5, the default value for the minFileSizeForComp is 2700.
Is your svg file too small? I config the httpCompression in IIS administrator GUI(not web.config) and it works well.
You can see the microsoft httpCompression config reference. sample code:
<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>
You can also use compressed .svgz file instead of .svg file for saving CPU.
To config gzip content encoding for .svgz file, see: How to add Encoding for specific file types?
<system.webServer>
<rewrite>
<outboundRules>
<rule name="Rewrite SVGZ header" preCondition="IsSVGZ" stopProcessing="true">
<match serverVariable="RESPONSE_Content_Encoding" pattern=".*" />
<action type="Rewrite" value="gzip" />
</rule>
<preConditions>
<preCondition name="IsSVGZ">
<add input="{PATH_INFO}" pattern="\.svgz$" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".svgz" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With