IIS 6 Page Compression
While looking into ASP.NET caching techniques, I ran across this little gem on IIS page compression using gzip.
IIS 6 has a built-in capability of compressing pages and / or content through gzip before sending it to the requesting client to cut down on bandwidth usage and overall network performance.
It’s also a smart process. First, there’s two types of compression that it will do. If it’s a static file (no dynamic content), it’ll zip up the file and store it in a temp space to send every time the page is requested. This way the CPU overhead is very minimal because it only has to compress the page once. The other is for dynamic pages. For these, it’ll compress the page as requested on the fly. This has a higher CPU usage, but worth it overall.
On top of that, it also checks the users browser for gzip compatibility before it even compresses the file. If it’s compatible (IE, Firefox, etc), it’ll send the compressed version. If the browser can’t handle compressed content, it’ll send the non-compressed version. Rock!
The downer is that it’s not very easy to setup (kinda). Meaning that there’s no checkbox anywhere to enable this and configure it. The guy over at AngryHacker.com (article above), wrote a great batch file that enables it and sets it up in one quick swoop. Make sure to save the BAT file in C:\Inetpub\AdminScripts
IISreset.exe /stop cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoDynamicCompression true cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoStaticCompression true cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcFileExtensions "htm" "html" "txt" "ppt" "xls" "xml" "pdf" "xslt" "doc" "xsl" "htc" "js" "css" cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcFileExtensions "htm" "html" "txt" "ppt" "xls" "xml" "pdf" "xslt" "doc" "xsl" "htc" "js" "css" cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx" "ashx" cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx" cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcDynamicCompressionLevel "9" cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcDynamicCompressionLevel "9" IISreset.exe /restart
If you’re not familiar with IIS, this script will stop your web server while it implements this and then start it back up once it’s done. Also, the default compression level is 0 (0-10), and this script sets it to 9. I have mine set at 9 and didn’t really notice much difference in CPU utilization.
Good stuff eh?
Nice site!