How to gzip svg files in ASP.NET

My previous post showed how to gzip svg files served by the Sitecore media library. This is fine if all svg files reside in the media library but this is typical not the case.

In this post I will show how to gzip compress any svg files served by your ASP.NET solution. As I explained in my previous post the issue that I am attempting to solve is that IIS will not by default gzip svg files without a lot of configuration changes on server level.

The solution here is extremely simple and pragmatic. Simply implement a HttpModule and set the Response.Filter stream to a GZipStream.

GZip svg files

Then add the httpmodule to configuration

That is it. I hope this helps someone out there in their own personal fight with Google PageSpeed.



Anders Laub

Anders Laub Christoffersen

Anders has been working with Sitecore for over a decade and has in this time been the lead developer and architect on several large scale enterprise solutions all around the world. Anders has been nominated a Sitecore Technical MVP three years in a row for 2014, 2015 and 2016. Anders is now working as a Sr. Solutions Architect at Sitecore in Copenhagen.

4 thoughts on “How to gzip svg files in ASP.NET

  1. I tried to implement gzip for font in so many ways but nothing worked. You solution worked like magic. Hats of man…genius better solution with full control.

Leave a Reply

Your email address will not be published. Required fields are marked *