How to GZip on ASP.NET and GoDaddy

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.

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.


  1. @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.

    Thanks! :)

  2. 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?

  3. 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.

  4. 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.

    1. 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. :)


  5. 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.

  6. 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.

  7. 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: it still says my page is uncompressed.

    Using firebug i cant find “Encoding” header as shown in the example… any tips?

  8. 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.


  9. 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)?

  10. 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)…

  11. 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:

    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.

    Jeeshen Lee

  12. 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

  13. 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.


  14. 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.. ?

  15. 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?

  16. 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

  17. 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…

  18. 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.

  19. 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/javascript; charset=utf-8″

    for Javascript file. Thanks.

  20. I had been researching this topic and came across your site. I happen to run my pages at Godaddy. The web.config code worked like a charm. The difference in speed is amazing.

    thank you very much!

  21. 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.

  22. Hi,

    I have referred as steps provided by you and below link and successfully implemented Gzip, by compressing aspx pages.

    My website is ajax enabled. One of page is having gridview.

    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,

  23. Hi jeeshenlee,

    i have added below code for gzip as per link

    protected override void OnPreRender(EventArgs e)


    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?

  24. 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?

  25. 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

  26. 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!!

  27. 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!

  28. 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.

  29. Ironically the entire httpCompression configuration element shown is being ignored. The only part of this post that is activating compression is the urlCompression configuration element. httpCompression can only be configured at the applicationHost.config level to apply to the whole server. The configuration shown here for that element happens to be the default which will already be in place on GoDaddy. So yah, you only need one line from this post FYI.

  30. hi everybody, well i used that code but i can not see the effect with page speed of google, i am proving with out publish, is it because i am in localserver? or what? my server is ISS

  31. What you published was actually very logical.

    But, think on this, suppose you added a little content?
    I mean, I don’t wish to tell you how to run your blog, but what
    if you added a title that grabbed folk’s attention?
    I mean How to GZip on ASP.NET and GoDaddy | JeeShen Lee 李毅胜
    is a little boring. You ought to peek at Yahoo’s front page and note how they write post headlines to grab viewers interested.
    You might try adding a video or a pic or two to grab people excited about everything’ve got
    to say. In my opinion, it could bring your posts a little bit more