Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Enable Gzip Compression in Asp.net using Web.Config to Improve Website Performance

Jul 16, 2014
Introduction:

Here I will explain how to enable gzip compression in asp.net using web.config file or add gzip compression in asp.net website using web.config file. Gzip compression is used to increase the page performance of website or application by compressing html, css, jquery, JavaScript etc files.

Description:

In previous post I explained Difference between cursor and while loop in sql server, Breadcrumb example in asp.net, how to pass table as parameter to stored procedure, Add Fade in effect to webpage using JQuery and many articles relating to asp.net, JQuery, Ajax etc. Now I will explain how to enable gzip compression in asp.net using web.config file to increase page performance of website.

Gzip compression is mainly used to improve performance of website by compressing project files for that we need to write the code like as shown below in web.config file


<system.webServer>
<httpCompression directory="%SystemDrive%\inetpub\
temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.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"/>
</system.webServer>

By setting above properties in web.config file automatically it will compress application files and it will help us to improve performance of website.

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

3 comments :

Unknown said...

Hi Suresh..Your posts greatly inspire most of us I believe. Could you please advise if above codes will work in all asp.net application or some attributes need to be customized depending on application. Look forward to your reply. Thanks in advance..Regds. Sat

Unknown said...

hiee..! suresh i was tested my website by Yslow addon and this code didn't compression..
please show me right solution.....Thanks in advanced....

Unknown said...

what about the directory path, is it same for all host

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.