Monday, October 13, 2008

Enabling HTTP Compression (IIS 6.0)

  1. In IIS Manager, double-click the local computer, right-click the Web Sites folder, and then click Properties.
  2. Click theService tab, and in the HTTP compression section, select the Compress application files check box to enable compression for dynamic files.
  3. Select the Compress static files check box to enable compression for static files.
  4. 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.
  5. 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.
  6. Click Apply, and then click OK.
  7. Created a web service extension for c:\windows\system32\inetsrv\gzip.dll
  8. Used metabse explorer or Adsutil.vbs to:
    a) edit the compression levels (set to level 9 for both HcDynamicCompressionLevel and HcOnDemandCompLevel) for both deflate and gzip.
    b) ensure that gzip was used for static compression only (HcDoStaticCompression set to 1) c) set HcFileExtensions (static files) for both gzip and deflate to htm,html,txt,js
    d) set HcScriptFileExtensions for both gzip and deflate to asp,dll,exe,aspx,asbx,ashx,asmx,axd,js and css (I have css files that are dynamically generated)
    e) set HcCreateFlags to 0 for deflate and 1 for gzip
    f) Checked that, underneath parameters, HcDoDynamic, HcDoStatic and HcDoOnDemand are set to 1.
    g) Other settings: Buffer sizes are set to 8192, HcMinFileSizeForComp is 1.
Samples for Adsutil.vbs:

To enable HTTP Compression for Individual Sites and Site Elements:

  1. Disable global static compression by executing the following command at a command prompt:
    adsutil set w3svc/filters/compression/parameters/HcDoStaticCompression false
  2. Enable static compression at this directory by executing the following command at a command prompt:
    adsutil set w3svc/1/root/Home/StyleSheets/DoStaticCompression true

To disable static compression for only a single directory, first enable global static compression (if it is disabled) and then disable static compression at that directory. For example, to enable static compression for a directory at http://www.contoso.com/Home/StyleSheets, perform the following steps:

  1. Disable global static compression by executing the following command at a command prompt:
    adsutil set w3svc/filters/compression/parameters/HcDoStaticCompression true
  2. Enable static compression at this directory by executing the following command at a command prompt:
    adsutil set w3svc/1/root/Home/StyleSheets/DoStaticCompression false

No comments: