Cory Rylan

My name is , Google Developer Expert, Speaker, Software Developer. Building Design Systems and Web Components.

Follow @coryrylan
Cory Rylan Blog

SVG gzip in Windows Azure

Cory Rylan

- 1 minute

Updated

When running a Windows Azure website you may run into a problem I came across with gzipping content. By default Azure websites are very easy to set up and have little maintenance cost. Most of the performance features are turned on by default with one exception. SVG images seem to not gzip on website instances.

Azure Websites seem to also ignore the web config overrides for this as well.

Unfortunately the way to turn this on is to use Web Roles. I did not want to deal with that hassle so I created a controller to handle incoming SVG requests as recommended from these two posts, [Stack Overflow](http://stackoverflow.com/questions/17029543/enable-gzip-compression-for-svg-in-azure-web-sites) and [Asp Weblogs](http://weblogs.asp.net/jongalloway/asp-net-mvc-routing-intercepting-file-requests-like-index-html-and-what-it-teaches-about-how-routing-works).

Thanks to David Ebbo (@davidebbo) he pointed me in the right direction in making a better solution. it turns out you can get gzip to turn on for SVG with the web config. The solution is below, as well as the comments.

<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml"/>
</staticContent>
<httpCompression>
<staticTypes>
<remove mimeType="*/*"/>
<add mimeType="image/svg+xml" enabled="true"/>
<add mimeType="*/*" enabled="false"/>
</staticTypes>
</httpCompression>
</system.webServer>
</configuration>

The key part I was previously missing was the <remove mimetype="*/*" />.
If you read the comments by David it seems that this will be fixed and turned on by default on the next Azure update.

Twitter Facebook LinkedIn Email
 

No spam. Short occasional updates on Web Development articles, videos, and new courses in your inbox.

Related Posts