Friday, June 08, 2007

Don't Forget IIS Compression!


A colleague mentioned today that he had been trying to reduce the page size of a web app he was building. One thing I do whenever I install IIS is to turn on HTTP Compression. In IIS 5, HTTP Compression was introduced, but was too flaky to actually use. IIS 6 does it right, but keeps the option "hidden" in the metabase file where no-one ever goes. In IIS 7, there will be a GUI option to configure it, but apparently it will be on by default.

Here are the instructions you need to turn on HTTP Compression for your Web-Front End servers and application servers. You should notice a significant improvement in load speed:



1. Right-click Internet Information Services in the Management Console; Click "Properties".

2. Check "Enable Direct IIS Metabase Edit".



3. Navigate through windows folder structure to this path: "C:\WINDOWS\system32\inetsrv".


4. Open the Metabase.xml file in Notepad.


5. Modify the IISCompression scheme element whose location ends in "gzip" and "deflate":



a. For both, set HcDynamicCompressionLevel = 9.


b. For both, set HcScriptFileExtensions="asp
dll
exe
aspx"
c. For both, set HcFileExtensions="htm
html
txt
xml"

2 comments:

  1. Hi Nick,
    You don't have to modify metabase.xml file manually, just use admin utilities in C:\Inetpub\AdminScripts\ directory.

    Excute the following command in CMD windows will enable most common file extentions for gzip/deflate compression.

    ============================
    CD C:\Inetpub\AdminScripts\ [Enter]

    cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcFileExtensions "htm" "html" "txt" "ppt" "xls" "xml" "pdf" "xslt" "doc" "xsl" "htc" "js" "css" [Enter]

    cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcFileExtensions "htm" "html" "txt" "ppt" "xls" "xml" "pdf" "xslt" "doc" "xsl" "htc" "js" "css" [Enter]

    cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx" "ashx" [Enter]

    cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx" [Enter]

    IISreset.exe /restart [Enter]
    ============================

    ReplyDelete
  2. Thanks Pure C#! That is a great tip and perfect for a SharePoint build script!

    ReplyDelete

Note: only a member of this blog may post a comment.