I'm trying to acomplish this in web.config:
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<httpCompression>
<staticTypes>
<add mimeType="image/svg+xml" enabled="true"/>
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true"/>
But Content-Encoding: gzip
never appears in response headers. Though, compression works good for other types like CSS.
❓ How can I compress a SVG image? First, you need to add a SVG image file: drag & drop your SVG image file or click inside the white area to choose a file. Then adjust compression settings, and click the "Compress" button. After the process completes, you can download your result file.
On the Server Roles page, expand Web Server (IIS), expand Web Server, expand Performance, and then select Static Content Compression and/or Dynamic Content Compression.
If you need to transmit SVG files quickly, you may want to compress those files before sending them to make them easier and faster. compress is particularly important if you need to send several files at once since a large group of files can slow down your network or processing speed.
iisbrotli. dll supports Brotli compression, while iiszlib. dll supports both Gzip and Deflate compression.
@Dominique Alexandre points to a solution that shows how you can edit the applicationHost.config file, which works just fine.
I just wanted to add how you can do this using the IIS Manager GUI.
Go to IIS Manager > YOUR_SERVER > Under Management section > Configuration Editor > Expand the system.webServer > httpCompression > dynamicTypes
And then add the mime types you want to be compressed additionally.
You need to turn it on for SVGs in IIS as a lower level. This post has the answer: https://stackoverflow.com/a/23940235/15233
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