Referring to the article “Best Practices for Speeding Up Your Web Site” from YUI, Gzip compression reduces the response time. Gzip compression generally reduces the response size by about 70% and approximate 90% of today’s internet traffic travels through browsers. After searching around for answer on how to implement gzip compression on ASP.NET application, I found the solution below is the easiest to implement.
Add the configuration shown below in the in web.config file. This configuration setup enable gzip compression on static and on dynamic content. I have tried it on GoDaddy’s Windows Shared Hosting and it works fine.
Enable Gzip compression in ASP.NET using web.config configuration.
<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>
This implementation is confirmed with Firebug as shown in the snapshot taken below.
I don’t get paid for writing blog posts. Your “Like” is my only motivation, so please “Like” it if you found this information useful. Cheers!!!
Check out what other says about this post by clicking at the title of this post.
Tagged: Add Gzip, Best Practices for Speeding Up Your Web Site, Compress CSS, Compress JavaScript, godaddy windows shared gzip, GZip, gzip godaddy, GZip on ASP.NET, GZip on Godday, httpCompression, httpcompression godaddy, IIS 7, Speed Web Site, step by step gzip


Give me a “Like” if you found this post useful. Thanks.
I had to add these extra types to both static and dynamic and then it worked a treat:
“application/x-javascript”
“application/javascript; charset=utf-8″
@David, glad that you find out about this.I’m not aware about that as the configuration posted works fine on my hosting account at GoDaddy. Thanks for sharing!
Can you share the name of your hosting provider? GoDaddy? Gator?
I just did a rough check on this topic and found out why “x-javascript” is different from “javascrip”, it has something to do with the MIME type. Check out the link below.
http://annevankesteren.nl/2005/02/javascript-mime-type
http://www.phpbuilder.com/board/showthread.php?t=10367548
Thanks!
Nice! Works like a charm.
really really nice job
Thanks, it works nice……!
This is excellent.
This alone upgraded my page speed score from 70 to 73 in Page Speed.
When I tried this , I got a 500 Internal Server Error.
I tried creating a web.config file and uploading that with your code in it. Where does your code go exactly?
Found the answer. The code you originally posted needs to be wrapped in a tag.
Hello Brian, the code is meant to be added to your existing web.config file. A new web.config file with these code alone won’t works as you need other configurations as well.
Anyway, i’m happy that you found the answer. Thanks for trying it out.
Ah, but I didn’t need any other configuration. This was all that I needed. The way I understand web.config files is that you can override the Server level web.config file with a file in the site’s root directory. GoDaddy most likely has their own server level file. So in this case, all I needed was the full structure of a web.config file and I was good to go.
Yes, you are right. GoDaddy does have the server level configuration file but you do need your own configuration file as well at the website level. I have just uploaded a default web.config file generated by Visual Studio 2010, you can use it.
Default Web.Config
Add the above Gzip compression to the default web.config, you should be good to go.
Thanks.
Ah. I realize now more of your confusion on why I didn’t need more of a web.config file. All I’m using it for is to handle GZip compression and Expires Headers. I’m actually running a ColdFusion site on GoDaddy. ColdFusion handles my database connections for me, so no connection strings. ColdFusion’s Application.cfm or Application.cfc handles my Login/Authentication (if needed). So the remainder of that web.config file you provided is not relevant for my site.
I do want to thank you for this post though – it did get me going in the right direction.
Haha, I see. Anyway, glad that my post helps though.
Thanks so much for this bit of code for the web.config file. It works really great and the difference in loading speed and amount of compression is just UNBELIEVABLE. Many many thanks.
[...] How to GZip on ASP.NET and GoDaddy August 2010 15 comments and 2 Likes on WordPress.com 4 [...]
Hi i followed the instructions on this post and i can’t get my website enconding to show gzip. Im using the following tool to check encoding type:
gidnetwork.com/tools/gzip-test.php it still says my page is uncompressed.
Using firebug i cant find “Encoding” header as shown in the example… any tips?
Hello Noel,
On firebug window, open the “Net” tab. Go to “All” tab and open up the page request in the list. Try to hit “Ctrl+F4″ to refresh if you can’t see the last page request. You should see something similar to my snapshot.
I tried to view my website using the link you gave and get “No” for webpage compress as well. I have no idea how the web app test the site. Can you try Yahoo YSlow? I used it as my benchmark wheh I play with gzip compression.
Thanks!
Thanks for your support jeeshenlee,
I tried your suggestions and can’t get it to work.
I have access to the hosting server ( i selected compression options from IIS), and still cant get css/js/aspx gzipped. This is very frustrating, is there any programatic solution (.net server side)?
I managed to get aspx pages compression working, however, i still can’t get to compress .js and .css (i have static and dynamic compression enabled on IIS 7.5)…
Hello Noel,
Given your access to the IIS configuration (on hosting server), you should have better access to configure the gzip compression. You may refer to the link below:
http://support.microsoft.com/kb/322603
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/25d2170b-09c0-45fd-8da4-898cf9a7d568.mspx?mfr=true
http://weblogs.asp.net/owscott/archive/2004/01/12/57916.aspx
For those who DO NOT have access to the IIS configuration (like me, using shared hosting) can use the suggested web.config setup to enable gzip compression.
Good luck. Cheers.
Regards,
Jeeshen Lee
Hello Noel,
Can you try the “types” suggested by on of this post’s commenter (David Madden, second commenter from the top)?
I already have dynamic and static compression enabled on iis 7.5 as i mentioned before, i tried david’s suggestion without luck… I guess this has something to do with the URL rewritter module im using, im investigating about this, anything else please let me know. Thanks
Hi,
Many thanks for the suggestion but my pages are not getting compressed. I am also using the Windows shared hosting in Godaddy and in my hosting path I have created two folders 1. ZipLipBinary & 2. temp and mapped the same to my web.config file like below
Please let me know whether I have missed anything. Thanks in advance.
-Shankar
Hello Shankar,
You may paste the above code in the root of your folder and have your default.aspx execute from the root. I guess that will help.
Thanks.
Hi,
I’ve searched FAR and wide for this solution.. haven’t tried it yet, but I’m not planning on using .net, I have asp and access all over my site. If I use this on a .net enabled server as well as asp, will it compress the asp files as well? I’m assuming it will since you’re using coldfusion and another guy mentioned php.. ?
Hello Rod, which version of IIS your hosting server is using?
Wow, Thanks for the quick response.
IIS 6.0
Eagerly awaiting your reply
Hello Rod, the code above are meant for IIS 7.
For IIS 6, you may refer to:
http://omaralzabir.com/iis_6_compression___quickest_and_effective_way_to_do_it_for_asp_net_compression/
http://weblogs.asp.net/owscott/archive/2004/01/12/57916.aspx
Hope that helps.
Good luck
That would help tremendously if my hosting company would install it on their server but they refuse to do it… hence me trying to find some work around.. ah, well.. I tried. Any other solution you can think of?
Hello Rod, I would suggest you to do some research on ISS 6 Web Config. In particular, the compatible config setting for “httpcompression”.
Found this link below that shows ‘httpcompression’ related setting in ISS 6.
http://www.iis.net/ConfigReference/system.webServer/httpCompression
Thanks.
Thank you!
[...] on Godday Window Shared Hosting. Refer the web.config configurations needed in this link – http://jeeshenlee.wordpress.com/2010/08/01/how-to-gzip-on-asp-net-and-godaddy/ August 1, 2010 7:35 [...]
JS, thanks for this useful post! I am currently working on a blog post too and it is about javascript optimization and I will make sure to put a link to your post here. I think everyone has to see it. It worked perfectly on the godaddy shared account. the gzip is able to cut down jQuery library code size to almost 30kb…it is amazing
@bennytija, sure.
Hi!
I have a problem… i inserted this code in right place, in my web.config are others settings, but they don’t affects to this code, isn’t it?
So when i inserted code, i tried in IE9 my website.. but i can’t see changes with code or within it code….
please help to me…
Hello Vladimir, yes to code won’t affect other configuration. Did you tried using Firebug to see the changes in the server response?
HEllo, jeeshenlee
mmm, no, i used included IE toll for web-developers.
but where i can see responses in firebug?
thanks for help
all works right
@Vladimir, awesome!
i tried ur technique but its giving 500 internal server error.. i have godaddy shared hosting for ASP.net.. here the link of my site
http://www.myunister.com
@Wahab Kotwal, just checked your site. It’s working, with gzip response too.
Nice article, good job my friend, this article was great for me, cause i use godaddy
Do you have any idea why this works on my local Windos 7 machine, but not on the production server Windows Server 2008 R2? I have enabled dynamic content compression both places.
Hi,
I have a GoDaddy Shared windows account and i tried this but when i am checking it on FireBug, it is still showing it as not GZipped.. and how can I check whether my JS or CSS are being compressed.
Thanks
You can check it using Firebug. Double check your web.config file especially the httpCompression node.
Check also the comment from @David Madden suggesting to
“application/x-javascript”
“application/javascript; charset=utf-8″
for Javascript file. Thanks.
I had been researching this topic and came across your site. I happen to run my asp.net pages at Godaddy. The web.config code worked like a charm. The difference in speed is amazing.
thank you very much!
nice stuff. thanks
Thanks so much for posting. Worked for me also.
Very disappointed in GoDaddy shared hosting for Windows. I can’t believe that they treat these server configuration options as “code” and just leave you stranded.
thanks so much. i use tme my site.
not working for me..
Hi,
I have referred as steps provided by you and below link and successfully implemented Gzip, by compressing aspx pages.
http://stackoverflow.com/questions/6939304/gzip-a-single-asp-net-page
My website is ajax enabled. One of page is having gridview.
Problem:
While debugging gridview rowCommand fires and records are displaying in debugging mode, but same records are not displaying on web page controls.
Can any1 help me out from this issue?
Thanks and BRegards,
Vijay
@Vijay, try turn on firebug and look at the http. I think the problem you are experiencing has nothing to do with the compression.
Hi jeeshenlee,
i have added below code for gzip as per link
http://stackoverflow.com/questions/6939304/gzip-a-single-asp-net-page
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
CompressionUtilities.GZipEncodePage();
}
by using above code it compresses the aspx page as shown by firebug,
gridview is getting populated
clicking on gridview rowcommand fires
records are displayed in debug mode
but records are not displaying on web controls like textBox
After removing above code, records are visible both in debug mode as well as on web controls, but pages are not compressed.
Does ajax updatepanel is causing it?
@Vijay, can you PM me the link to your website? would love to take a look.
hi jeeshenlee,
have tried various browser..
google chrome: working smoothly
firefox: problem as mentioned
ie: problem as mentioned
Hi, I know it’s been 2 months since the last post but…
After getting this to work, my @font-face broke for IE, Firefox, and Opera, but not Chrome. I checked in firebug and my .tff and .woff are 404ing. I think it has something to do with mimetypes but I know woefully little about that.
The main reason I decided to look into gzipping was to cut down the FOUT. Can I modify this method, perhaps adding a new <add mimeType so that my font files will also be gzipped and display properly?
Thank you for posting this article..it help me a lot.
Hi. I copied your code in my web.config but if you check my wite with firebug, you see that it don’t work,
I use arvixe share hosting.
what can I do now? can I reffer to gzip.dll in my bin folder?
Great. Working perfect. Thanks…
Hi there! i’m using Godaddy’s Web Deluxe Windows hosting service. And i want to implement Gzip compression, though above you mentioned is not working for me.
Here is the URL: http://www.mund-consulting.com
Lastly,Can you please also shed some light on implement Add Expires headers (css,js,html,image).
Thanks.
Hi there
This is very useful (it’s probably even worth you stating somewhere that this is not just specific to GoDaddy – it should work on any hosting).
I have a question for you. Does this method *only* gzip content if the requesting browser sends headers to say that it accepts gzip’d content, or does it gzip content for *every* request?
Thanks again
Cheers
Matt
Oh my goodness! Impressive article dude! Many thanks, However I am going through difficulties with your RSS. I don’t know the reason why I am unable to join it. Is there anybody else getting the same RSS problems? Anyone who knows the solution will you kindly respond? Thanks!!
here’s xml rss feed link http://jeeshenlee.wordpress.com/feed/
I need to do the gzip compression for IIS 6.0….please help
There was no native web.config file for our site, so I copied and pasted the above code into a new xml file and added it to the file manager on godaddy…but the site then gave a 500 internal error immediately after. Is there a reason this would happen? I’ve since deleted the file since we can’t afford for the whole thing to be down like that, but I’m wondering if there’s something I’ve missed in the code, or if there’s any other way to do this. Any feedback would be much appreciated!
@Mara, are your web run on IIS? and is it a ASP.NET website? If yes, you should be able to find the web.config. And the code above are part of the web.config file, you can find the complete standard web.config file here
http://support.microsoft.com/kb/815179
Thanks! this worked like a charm for my godaddy instance.
Simply want to say your article is as astonishing.
The clearness in your post is just excellent and i could assume you’re an expert on this subject. Fine with your permission let me to grab your feed to keep updated with forthcoming post. Thanks a million and please carry on the gratifying work.
[…] How to GZip on ASP.NET and GoDaddy […]