August 22, 2004
HTTP compression is the ultimate no-brainer. The network is really slow, and CPU time is effectively free and geting faster and, uh, "free-er" every day. Compression typically reduces plaintext size by 75 percent: that quadruples your throughput! Every website should be serving up HTTP compressed pages to clients that can accept it. The client indicates ability to accept compressed contents in the request headers:
GET /blog/index.xml HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
HTTP compression was available in IIS 5.0, but it was also horribly broken. I know that's a link from a vendor selling a competing product, but I can personally vouch for this-- it sucked. Don't enable compression in IIS 5.0. It's not worth the pain it will inevitably cause you. Fortunately, there is an alternative-- the free FlatCompression ISAPI filter. It's not very sophisticated. All outgoing content of the specified mime type(s) is blindly compressed in real time with no caching, so it's ideal for sites with mostly dynamic content. Most importantly: it actually works, unlike the built in IIS 5.0 compression, and it's free open source. If you control an IIS 5.0 server, you should have the FlatCompression ISAPI filter installed.
One of the things I was looking forward to in IIS 6.0 was a HTTP compression layer that actually worked. I thought I had HTTP compression enabled correctly in IIS 6.0 in the Properties, Service tab, but after looking at some sniffer traces.. not quite. I followed a few walkthroughs, such as the excellent Enabling HTTP Compression in IIS 6.0, and I was still getting spotty results. A few observations on my troubleshooting:
- Adding the IIS compression filter .dll to the extension manager made absolutely no difference on my server. I'm not sure why people think they need to do that; It has no effect for me, and I tried it both ways a few times.
- Despite what the MS documentation says, the metabase filename extension lists are not space delimited! They are cr/lf delimited.
- You must restart IIS to get it to reload any changes you've made to the metabase.
- There appear to be some non-obvious metabase entries that will prevent compression of script output.
- Setting the file extensions to "blank" does not cause IIS to compress all content as specified in the documentation.
Getting a variety of static content extensions to compress was easy, but I had an absolute rip of a time getting dynamic script output to compress. You know, .cgi (perl), .aspx, .asmx, etcetera. I followed every suggestion out there with no joy-- the sniffer kept showing uncompressed dynamic output coming back, but all the static files I tried came back compressed just fine. I'm still not sure which metabase setings I changed to get it to work, so I will post the current working version of the relevant IIS metabase sections in their entirety:
<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/deflate"
<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/gzip"
<IIsCompressionSchemes Location ="/LM/W3SVC/Filters/Compression/Parameters"
HcCompressionDirectory="%windir%\IIS Temporary Compressed Files"
HcExpiresHeader="Wed, 01 Jan 1997 12:00:00 GMT"
The last things I tried were modifying the HcNoCompression* settings, and turning HcDoStaticCompression on for gzip. It's likely one of those.
I enabled HTTP compression for the .cgi script filetype, which covers the PERL scripts that Movable Type uses, and the interface was just blasting on the screen after I did that. It's truly amazing how much faster pages appear to load, even over a 100baseT local network, with HTTP compression enabled. It is dramatic. I can only imagine how much snappier pages load over a remote network.
Posted by Jeff Atwood
I havent looked into IIS6 ("completely new and much better than IIS5)", so I assumed that MS would have fixed the compression thing. However, this seems not to be the case.
Would it make sense to port FlatCompression to IIS6?
Hey Uli! Great to hear from you again.
We still use your excellent FlatCompression dll on our IIS5 servers at work with great success!
As for IIS6, the compression is fixed, it's just kind of a pain to configure. The documentation is flat-out wrong in a lot of places and misleading in others. But once you get it configured, it does work..
this gives additional data points on actual performance before and after enabling compression. There is some coverage about SSL with compression.
Dr. Uli's code is about 3 years out of date. It uses the zlib library, and the source shows quite an old version. I wonder if it's vulnerable to the recently found and fixed zlib buffer overflow vulnerability he predicted in his readme notes?
this gives additional data points on actual performance before and after enabling compression.
Interesting.. so on relatively old 500mhz and 700mhz processors, IIS compression increases CPU utilization 25-35% for dynamic pages (compressed each time). And only 10% for SSL since the SSL overhead is already so high. Not bad!
These are old posts but I'd like to add my 2 cents. My IIS 6.0 HTTP compression was not working because I had a McAfee virus scanner running in parallel. Once I turned off the On Access Scan, it started to compress the downloaded files.
Can you tell me how to determine if http compression is enabled? My site is not hosted on my own server so i can't see that in the iis manager.
Any help would be appreciated.
When I use the compressing, I receive for one of my pages a blank screen. When I open the page in notepad I get the following:
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
META http-equiv=Content-Type content="text/html; charset=utf-8"/HEAD
For all other pages the compression seems to be working fine..
Any ideas on this one?
For those posters wanting to know how to check if compression is enabled on their internal servers, here is the answer. You need to see the headers returned by your server, there are several ways to do this.
You could use a packet sniffer (Wireshark), an http proxy (proxomitron, fiddler) or a browser plugin (firebug for firefox). My personal favourite is Firebug as it allows you to see a lot more information about your site's performance, especially if you download the YSlow addon.
Alternatively, if you download the Pipeboost demo from port80, there is a header analyser tool included.
I can't get this to work w/ IIS on Windows XP Pro because the inetmgr doesn't have things like snapins and stuff..can't even find a metabase file
works like a charm, superkewl post :
Here's the command line options to set it all up:
ADSUtil.vbs Set W3SVC/Filters/Compression/Parameters/HcDoStaticCompression TRUE
ADSUtil.vbs Set W3SVC/Filters/Compression/Parameters/HcDoOnDemandCompression TRUE
ADSUtil.vbs Set W3SVC/Filters/Compression/Parameters/HcDoDynamicCompression TRUE
ADSUtil.vbs Set W3SVC/Filters/Compression/deflate/HcDoStaticCompression TRUE
ADSUtil.vbs Set W3SVC/Filters/Compression/deflate/HcDoOnDemandCompression TRUE
ADSUtil.vbs Set W3SVC/Filters/Compression/deflate/HcDoDynamicCompression TRUE
ADSUtil.vbs Set W3SVC/Filters/Compression/deflate/HcFileExtensions "asx" "css" "doc" "htm" "html" "js" "txt" "xml"
ADSUtil.vbs Set W3SVC/Filters/Compression/deflate/HcScriptFileExtensions "asp" "ashx" "asmx" "aspx" "axd" "dll" "exe" "svc"
ADSUtil.vbs Set W3SVC/Filters/Compression/deflate/HcOnDemandCompLevel 10
ADSUtil.vbs Set W3SVC/Filters/Compression/deflate/HcDynamicCompressionLevel 9
ADSUtil.vbs Set W3SVC/Filters/Compression/gzip/HcDoStaticCompression TRUE
ADSUtil.vbs Set W3SVC/Filters/Compression/gzip/HcDoOnDemandCompression TRUE
ADSUtil.vbs Set W3SVC/Filters/Compression/gzip/HcDoDynamicCompression TRUE
ADSUtil.vbs Set W3SVC/Filters/Compression/gzip/HcFileExtensions "asx" "css" "doc" "htm" "html" "js" "txt" "xml"
ADSUtil.vbs Set W3SVC/Filters/Compression/gzip/HcScriptFileExtensions "asp" "ashx" "asmx" "aspx" "axd" "dll" "exe" "svc"
ADSUtil.vbs Set W3SVC/Filters/Compression/gzip/HcOnDemandCompLevel 10
ADSUtil.vbs Set W3SVC/Filters/Compression/gzip/HcDynamicCompressionLevel 9
IIS Reset, clear your cache, open Fiddler, open IE, make a request and voila, compressed content! One thing to note that on the dynamic level compression happens with each request. The blogosphere statea that the trade-off between levels 9 and 10 for dynamic compression is such that you will want to consider 9 because it takes exponentially less CPU versus the benefit.
I have a question..
Is it normal for compressed aspx to load slower, like 10 seconds slower? The pages were all compressed but somehow they are now loading slower..
The only issue I had was my metabase would revert after restarting IIS. The trick... right click the computer in IIS, and check "Enable Direct Metabase Edit"
My bandwidth compression has reduced by 45% - Hooray !!
But, YSlow still tells me that the files for my home page (include css, js, aspx) are not zipped. When I point my site to compresscheck (http://www.port80software.com/products/httpzip/compresscheck), I am shown a 65% drop in file sizes. I am not able to identify if ALL file types are getting compressed correctly by my IIS 6.0 server !
Any tricks/tips will be of great help - Thanks
After enabling compression in IIS, if your using YSlow you need to press CTRL + F5 to get the new compressed data. The first time IIS serves up the file it serves it up uncompressed so all the other times IIS can serve it up compressed.
Also if you were doing testing playing with IIS compression and caching you need to press CTRL + F5 to get IIS to serve up some freshly modified data after each modification of the metabase.xml file.
You may want to add anything output from amx, as this will include JS generated for .net validation controls and the like.
One thing we did notice was that if you have large jpegs in the page, then the compression can be worse. Basically the HTTP compressor is trying to compress something that's already very well compressed.
Otherwise the instructions here have been a huge help to us.
All of the above suggestions still not enough when iis is on sbs 2003 with isa 2004.
If you have that combo you need to enable the compression (even when the clients are internal) in isa server 2004:
Configuration/General/Define Http Compression Preferences
I would checkout www.ZipEnable.com. I know free is the best price, but like anything, less work/stress pays for itself in many other ways.
My IIS have active HTTP compression, i have a web aplication installed that use pages .aspx, then I want know what is the best tool to measure the consumption of bandwidth.
I wait for you answer.
Thanks for you help.
I actually went came to this post about 2 weeks ago and took a look at the product, ZipEnable, at the Port80 Software website (www.Port80Software.com) and after evaluation, I do not know how I survived so long without it. It gives you an amazing array of compression features without sacrificing system resources.
I also saw httpZip (www.httpZip.com) on their website, and it seems like a very useful product as well, catering to those outside the IIS 6 spectrum. I also see that you can use httpZip on IIS 6 as well!
Hope this helps anyone for future reference.
I found your site http://www.codinghorror.com/blog/archives/000059.html is good stuff for IIS HTTP Compression.
I am experiencing login issue with sharepoint central admin site, since we activated compression on websites(through IIS Manager) enabled on Sharepoint central admin site,
I followed the steps as below for activation, after rebooting server we have login issue with Sharepoint central admin site, I did n't created any web service extensions yet since i deactivated compression after we have login issue.
i thought http compression was enabled on Sharepoint central admin site, what should be additional steps needs to make it work.
Any help/workaround would be appreciated!!!
To enable global HTTP compression by using IIS Manager
In IIS Manager, double-click the local computer, right-click the Web Sites folder, and then click Properties.
Click theService tab, and in the HTTP compression section, select the Compress application files check box to enable compression for dynamic files.
Select the Compress static files check box to enable compression for static files.
In the Temporary directory box, type the path to a local directory or click Browse to locate a directory. Once a static file is compressed, it is cached in this temporary directory until it expires, or the content changes. The directory must be on the local drive of an NTFS–formatted partition. The directory cannot be compressed or shared, and the access control lists (ACLs) for the directory must include Full Control access to the identity of the application pool or to the IIS_WPG group.
Under Maximum temporary directory size, click a folder size option. If you specify a maximum size under Limited to (in megabytes) (the default setting is 95 MB), then when the limit is reached, IIS automatically cleans up the temporary directory by applying the "least recently used" rule.
Click Apply, and then click OK.
I have enabled IIS compression on my server which hosts two websites. Weird thing is compression is working for one of the websites, but not the other. What steps can I take to diagnose why this is happening.
Also, on our internal testing servers, how do I check that compression is working? Since the port80 link you gave only works for sites on the internet. What is this sniffing you mentioned?
Thanks in advance :)
I ran into the same problem that you did in getting dynamic script (particularly .JS files) to compress properly. I finally got it working by manually editing the Metabase and moving the JS filetype from the HcFileExtensions to HcScriptFileExtensions.
Oddly, the same thing was happening for CSS files as well.
Even houses that are newly built is able to have water enter through the septic system or fissures in the foundation. Eextremely basement is susceptible diaphragm valve to flooding, so to prevent basement flooding you have to be proactive. New homes can have basement flooding problems gate valve too. Although I have not even scratched the surface in holding tank maintenance if you do a quick search on the net will reap you some very good tips that you can add to those few that I have provided here. And just a little water leaking into homes with a finished basement can be detrimental, and sampling valve cause thousands in repair costs. Basement leakage, and basement flooding, are common issues that a home has to deal with.
Thanks. I was banging my head with compression until I read the line in this post that said "Despite what the MS documentation says, the metabase filename extension lists are not space delimited! They are cr/lf delimited." So true. CRLF and iisreset and it went from JSON 101KB to 4KB.