IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

IIS 6 has builtin gzip compression ability which can compress output of dynamic webpages (.aspx) and webservices (.asmx). The compression is really good and can easily reduce 60% download time. You should always turn this feature on in your production server. The CPU usage is not that high compared to the reduction of download time for users. Your users will love the significant download time reduction when you turn it on.

Now, on internet you will find a lot of solutions. I tried all of them which appears in first 30 Google search results. But failed to make any of them work properly. Finally I was able to make it work, but I realized you have to do it in a very specific way and in specific order. Here it goes:

  • Go to IIS Manager from Administrative Tools
  • Right click on your computer name (not on websites or Default Web Site)
  • Choose All Tasks-> Restart IIS
  • From the drop down, choose "Stop IIS" and click OK.
  • IIS is not stopped. Make sure it's not still running
  • Now go to C:\WINDOWS\SYSTEM32\INETSRV
  • Make a copy of the file Metabase.xml. This is a dangerous file, don't play around with it. Make sure you have a backup before you do what I am going to tell you now.
  • Open the metabase.xml in Notepad. Don't use any other editor besides Notepad, Notepad2 or Visual Studio.
  • Find using "<IIsCompressionScheme"
  • You will find a match which looks like this: "<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/deflate"
  • Now t
  • here are 2 nodes which are <IISCompressionsScheme> and one node which is <IISCompressionsScheme s > Note: the 3rd one is plural.
  • Delete these nodes. After deleting you will see the next node is "<IIsWebInfo Location ="/LM/W3SVC/Info"
  • Once you have deleted the 3 nodes, paste the following exact in their position:
<IIsCompressionScheme Location
="/LM/W3SVC/Filters/Compression/deflate"

HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="0"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="9"
HcFileExtensions="htm
html
xml
css
txt
rdf
js"
HcOnDemandCompLevel="9"
HcPriority="1"
HcScriptFileExtensions="aspx
asmx
asbx
ashx
axd
php"
>
</IIsCompressionScheme>
<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/gzip"
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="1"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="9"
HcFileExtensions="htm
html
xml
css
txt
rdf
js"
HcOnDemandCompLevel="9"
HcPriority="1"
HcScriptFileExtensions="aspx
asmx
asbx
ashx
axd
php"
>
</IIsCompressionScheme>
<IIsCompressionSchemes Location ="/LM/W3SVC/Filters/Compression/Parameters"
HcCacheControlHeader="max-age=86400"
HcCompressionBufferSize="8192"
HcCompressionDirectory="%windir%\IIS Temporary Compressed Files"
HcDoDiskSpaceLimiting="FALSE"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcExpiresHeader="Wed, 01 Jan 1997 12:00:00 GMT"
HcFilesDeletedPerDiskFree="256"
HcIoBufferSize="8192"
HcMaxDiskSpaceUsage="99614720"
HcMaxQueueLength="1000"
HcMinFileSizeForComp="1"
HcNoCompressionForHttp10="TRUE"
HcNoCompressionForProxies="TRUE"
HcNoCompressionForRange="FALSE"
HcSendCacheHeaders="FALSE"
>
</IIsCompressionSchemes>

You should not copy & paste the above. Download the file from this URL and open it in notepad and then copy the text.

IIS 6 Metabase configuration for turning on gzip

Now start IIS and hit your site once. When it runs for the first time, it will send uncompressed output, but it will compress it behind the scene. So, next hit will give you the compressed output.

Go to www.pipeboost.com and enter the URL to ensure you are getting compressed content. Before you do so, make sure you have visited your site for a while in your local browser so that the pages got the chance to get themselves compressed.

Published Thu, Aug 10 2006 6:59 by omar

Comments

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Saturday, December 16, 2006 10:51 PM by Shiva Shankar P

Very informative, thanks.

Since IIS 6 dynamic compression is CPU intensive due to lack of caching, i use .NET compression libraries to compress and use the Cache.VaryByCustom property on the page to choose the appropriate output.  All this gets abstracted into the base page class.

Is there any specific reason why you wouldn't prefer this solution?

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Tuesday, January 02, 2007 6:03 AM by Paulo Medronho

Great Info, but i've heard that deflate is about 41% faster than gzip, any ideias on how to give Priority to that compression? thanks

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Tuesday, January 02, 2007 6:23 AM by omar

Browser sends which compressions scheme it wants. Generally "gzip, deflate" is sent which means gzip gets higher priority.

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Friday, March 23, 2007 9:10 AM by Rachit

Omar,

How can we say if the aspx page is compressed using the above compression changes? i.e I can see compressed css or js files but I don't see anyting related to aspx or asmx!

BTW, this config works like a charm.

Rachit

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Friday, March 23, 2007 11:54 PM by omar

You can see the difference in size with and without compression.

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Wednesday, March 28, 2007 3:38 PM by Rachit

Omar, just an fyi:

If you are using Crystal Reports (I'm using ver 10.x) and if an aspx is responsible for the PDF/Excel download (e.g http://localhost/crystal.aspx will have response content type = pdf stuff), this compression will NOT work for those pages. So, in order it to work, one will have to remove "aspx" extension from your above code snippet.

Let me know if you know any workaround to this.

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Thursday, March 29, 2007 9:00 AM by omar

Very useful information. Thank you.

How about you use http://localhost/crystal.ashx and remove .ashx from IIS Compression list?

# Enabling HTTP compression on IIS 6.0

Monday, May 21, 2007 7:55 AM by Derek Mitchell

Recently I was looking for ways to improve the performance of my new Community Server 2007 installation

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Wednesday, May 30, 2007 8:29 PM by Richard

Im using an httpmodule to dynamically rewrite my apsx pages to seo friendly urls which dont have extensions.

Can I set up the compression to work for these pages.  If tried a * and a / in my extensions list but neither work.

Cheers

Rich

# robinzhong&#8217;s blog - links for 2007-06-06

Wednesday, June 06, 2007 3:17 PM by robinzhong’s blog - links for 2007-06-06

Pingback from  robinzhong&#8217;s blog   - links for 2007-06-06

# robinz&#8217;s tech life &raquo; Blog Archive &raquo; links for 2007-06-07 &raquo; Enjoying Open Source!

Pingback from  robinz&#8217;s tech life  &raquo; Blog Archive   &raquo; links for 2007-06-07 &raquo; Enjoying Open Source!

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Monday, August 06, 2007 10:54 AM by Mahesh

Hai,

    I had followed all the steps mentioned above but when i checked with fiddler tool i found that no files are compressed.

    Could you help me

# Using GUIDs as row identifiers

Monday, November 05, 2007 7:48 PM by Using GUIDs as row identifiers

Pingback from  Using GUIDs as row identifiers

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Wednesday, November 14, 2007 5:10 AM by free limewire

salet.tripod.com/.../91572.html

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Thursday, November 15, 2007 4:56 AM by George

padonki.info/.../56283.html

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Friday, November 16, 2007 12:15 AM by craiglist

<a href=jorik.info/.../96408.html>cheep airline tickets</a>

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Friday, November 16, 2007 1:29 AM by bankrupcy

<a href=polyaki.tripod.com/.../nightmare-before-chirstm.html>nightmare before chirstmas mp3</a>

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Friday, November 16, 2007 2:45 AM by monster ***

Hello, my name is Greg, I like yours blog, senks.

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Monday, November 19, 2007 5:33 AM by kelly bluebook

payday-loans.lookera.net

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Wednesday, November 21, 2007 5:34 AM by homepage

young-pussy4032.lookera.net

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Friday, December 07, 2007 6:18 PM by Upyachka

www.sotawesip.com/.../silver-christmas-tree.html

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Friday, January 18, 2008 8:04 AM by Prasant

It works fine when we use "localhost" in url but it doesn't work when i use IP Address  in url.

Any suggestions?

Thanks,

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Wednesday, February 13, 2008 11:16 AM by Pradeep

Are there are any known issues using IIS6 Compression?

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Wednesday, May 07, 2008 6:16 AM by Sambo

Great article,

Thanks

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Friday, June 06, 2008 8:58 AM by John

Have you ever managed to do this for when a wildcard is in place?

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Wednesday, July 23, 2008 6:44 AM by Manisha

There are 4 servers in the cluster. When i tried this on the first Webserver it was fine then on consecutive 2nd  and 3rd, it was finely working. As soon as , i enabled the compression on the 4th server, all went down. Then i had to revert back the  changes done in Metabase.xml  file. Then the application start working again. Can anybody help me in this regard.

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Thursday, July 24, 2008 3:08 AM by omar

Looks like you have a load balancer which looks for something on the webserver to see whether the servers are alive. When you turned on compression on all 4 servers, it does not see what it wants to see from any of the server and thus puts off the site.

PLease see if your load balancer is set to expect something from the webservers.

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Friday, August 01, 2008 9:37 AM by Terry

Has anyone had trouble with IE6 SP1 using this compression method? The is a KB article that suggests a problem support.microsoft.com/.../825057

Could any of these settings be tweaked to accomodate this browser version?

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Tuesday, September 09, 2008 11:43 PM by Prashant

sorry guys i did not find metabase.xml in "C:\WINDOWS\SYSTEM32\INETSRV".

Can you please suggest me what should i do???

thanks in advance

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Monday, October 06, 2008 2:15 AM by Kourosh Saleh

Hi and thanks, it's very good

I have just a question, what about win server 2008. Can I do same for 2008?

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Wednesday, October 29, 2008 6:59 AM by Andre du Preez

THIS ROCKS MAN!!!  So much faster...

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Thursday, November 06, 2008 5:57 PM by mcse training

Can we use the GZIP library with function calls from a PHP file?

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Friday, January 09, 2009 12:59 AM by Gordon Zuehlke

Tuesday, September 09, 2008 11:43 PM by Prashant:

sorry guys i did not find metabase.xml in "C:\WINDOWS\SYSTEM32\INETSRV".

//////////////////////////

Prashant,

?!?!

First, make sure you're using Server 2003 not XP Pro, then make sure you have installed the Application Server option in the "Configure My Server" 2003 wizard. If it's still not there, try re-installing the App Server manually.

gordon

# re: IIS 6 Compression - quickest and effective way to do it for ASP.NET compression

Friday, January 30, 2009 10:14 AM by Francis

Have you guys ever checked out ZipEnable or httpZip? They are at www.Port80Software.com.

Very amazing product that saved me a LOT of time and headache (and hair-because now I don't have to pull it out trying to get my IIS to compress properly).

Well worth the money and I would personally recommend it!

Thanks!

FJ

# IIS 6 Compression - Dynamic Pages without extensions

Tuesday, February 10, 2009 4:58 AM by Felipe Seixas

Hi Omar,

Excelent post, works for me on the first try =D

But I have a doubt. My web site uses MVC framework, my dynamic pages don't have an extension, like www.mysite.com/Home/Welcome, not www.mysite.com/home/welcome.html.

How do the HTTP compression on this cases?

Thanks in advance and thank you for the blog!

Leave a Comment

(required) 
(required) 
(optional)
(required)