Enabling Gzip in your web.config file

gzip-iconIn this guide we are going to show you how to enable Gzip on our Windows hosting packages. Gzip is a file format used for file compression and decompression. The most common text based files are HTML, CSS, XML and Javascript. The main thing about Gzip is that it helps to increase the speed of a website.

For example jquery-1.11.0.js uncompressed is 276 KB however with Gzip enabled it’s 82 KB, providing a compression of 70%. This can dramatically decrease the websites loading times and also helps you save bandwidth.


How to enable Gzip

If you don’t already have a web.config file you will need to create one.

You can then add the following example code:

//Gzip
 <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
  <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
   <dynamicTypes>
    <add mimeType="application/javascript" enabled="true"/>
    <add mimeType="application/json" enabled="true"/>
    <add mimeType="application/rss+xml" enabled="true"/>
    <add mimeType="application/vnd.ms-fontobject" enabled="true"/>
    <add mimeType="application/x-font-opentype" enabled="true"/>
    <add mimeType="application/x-font-truetype" enabled="true"/>
    <add mimeType="application/x-font-ttf" enabled="true"/>
    <add mimeType="application/x-javascript" enabled="true"/>
    <add mimeType="application/xhtml+xml" enabled="true"/>
    <add mimeType="application/xml" enabled="true"/>
    <add mimeType="font/eot" enabled="true"/>
    <add mimeType="font/opentype" enabled="true"/>
    <add mimeType="font/otf" enabled="true"/>
    <add mimeType="image/svg+xml" enabled="true"/>
    <add mimeType="image/vnd.microsoft.icon" enabled="true"/>
    <add mimeType="message/*" enabled="true"/>
    <add mimeType="text/*" enabled="true"/>
    <add mimeType="*/*" enabled="false"/>
   </dynamicTypes>
   <staticTypes>
    <add mimeType="application/javascript" enabled="true"/>
    <add mimeType="application/json" enabled="true"/>
    <add mimeType="application/rss+xml" enabled="true"/>
    <add mimeType="application/vnd.ms-fontobject" enabled="true"/>
    <add mimeType="application/x-font-opentype" enabled="true"/>
    <add mimeType="application/x-font-truetype" enabled="true"/>
    <add mimeType="application/x-font-ttf" enabled="true"/>
    <add mimeType="application/x-javascript" enabled="true"/>
    <add mimeType="application/xhtml+xml" enabled="true"/>
    <add mimeType="application/xml" enabled="true"/>
    <add mimeType="font/eot" enabled="true"/>
    <add mimeType="font/opentype" enabled="true"/>
    <add mimeType="font/otf" enabled="true"/>
    <add mimeType="image/svg+xml" enabled="true"/>
    <add mimeType="image/vnd.microsoft.icon" enabled="true"/>
    <add mimeType="message/*" enabled="true"/>
    <add mimeType="text/*" enabled="true"/>
    <add mimeType="*/*" enabled="false"/>
   </staticTypes>
  </httpCompression>
 <urlCompression doStaticCompression="true" doDynamicCompression="true"/>
//End Gzip

The above code will compress text files, HTML, CSS , XML and JavaScript files You can add more file types by adding their mime type.


Rate this post 1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

This entry was posted in General, Tips & Tricks, Windows, ASP & .NET and tagged , , . Bookmark the permalink.

Leave a Reply

Please DO NOT use this form to submit support requests, all information submitted will be PUBLICLY VISIBLE.

Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.