Add GZip compression to your asp.net site

November 5th, 2012 by admin Leave a reply »

I have been recently looking at ways to speed up performance on my website and I came across GZip compression, which is a great way to compress your javascript and css files before they come down to your system. A few of the benefits of this method are:

You can control what files are compressed.
Bots / SE spiders will crawl your pages faster than before
Decrease Bandwidth

Of course there is the drawback of the performance hit your server will take by running the compression on your files as they are being served, so you have to weight that into consideration as well. I have put below the code you have to add to your web.config file to get it going with asp.net, it goes in the section, enjoy:

<httpCompression directory="%SystemDrive%inetpubtempIIS Temporary Compressed Files">
      <scheme name="gzip" dll="%Windir%system32inetsrvgzip.dll"/>
      <dynamicTypes>
        <add mimeType="text/*" enabled="true"/>
        <add mimeType="message/*" enabled="true"/>
        <add mimeType="application/javascript" enabled="true"/>
        <add mimeType="*/*" enabled="false"/>
      </dynamicTypes>
      <staticTypes>
        <add mimeType="text/*" enabled="true"/>
        <add mimeType="message/*" enabled="true"/>
        <add mimeType="application/javascript" enabled="true"/>
        <add mimeType="*/*" enabled="false"/>
      </staticTypes>
    </httpCompression>
    <urlCompression doStaticCompression="true" doDynamicCompression="true" />

Advertisement

Leave a Reply