Reputation: 10731
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.
Upvotes: 11
Views: 14477
Reputation: 7701
In my case, image/svg+xml
was already listed as a mime type under <staticTypes>
but it still wasn't working. On a whim I also added the mime type to <dynamicTypes>
and that solved the problem.
Upvotes: 1
Reputation: 555
@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.
Upvotes: 5
Reputation: 10731
Not relevant, see Dominique Alexandre solution
OK, no one has answer. So I'll post here my temporary workaround.
I changed the mime type to text/xml, so it gets GZipped by IIS:
<mimeMap fileExtension=".svg" mimeType="text/xml" />
Upvotes: -2
Reputation: 8169
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
Upvotes: 3
Reputation: 104
Changing the mime-type is really not nice.
See this post instead on how to implement a custom httpmodule which does the gzipping for you in a few lines of code.
http://laubplusco.net/gzip-svg-files-asp-net/
Upvotes: 0