Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make IIS compress .svg files?

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.

like image 324
Evgenyt Avatar asked Oct 04 '12 19:10

Evgenyt


People also ask

How do I compress SVG files?

❓ 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.

How do I enable compression in IIS?

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.

Do you need to compress SVG files?

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.

Does IIS support Brotli?

iisbrotli. dll supports Brotli compression, while iiszlib. dll supports both Gzip and Deflate compression.


2 Answers

@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.

like image 169
Hauke S Avatar answered Oct 05 '22 10:10

Hauke S


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

like image 38
Sprintstar Avatar answered Oct 05 '22 11:10

Sprintstar