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. |
|||
|
|||
3 comments :
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
hiee..! suresh i was tested my website by Yslow addon and this code didn't compression..
please show me right solution.....Thanks in advanced....
what about the directory path, is it same for all host
Note: Only a member of this blog may post a comment.