2008-12-14

Enabling HTTP Compression in IIS 6.0

To enable HTTP compression in IIS 6.0

1. Open IIS Manager.
2. Right click Web Sites node and choose Properties.
3. Select Service tab.
4. Check Compress application files to enable dynamic compression.
5. Check Compress static files to enable static compression.
6. Click Browse next to Temporary directory: field and navigate to the folder where you will keep compressed files.
7. Choose whether you will be limiting temporary files directory size or not and click OK. (screenshot)
8. Go to Web Services Extension node and click Add new Web service extension..
9. Enter Extension name for example "HTTP Compression" click Add then in the Add file window click Browse and navigate to "C:\windows\system32\intetsrv" find gzip.dll select it and click Open. Click OK and OK again.
10. In the Web Service Extension list select "HTTP Compression" you've just added change its status to Allowed by clicking Allow button found on the left. (screenshot)
11. In IIS Manager right click your server node and choose Properties.
12. Check Enable Direct Metabase Edit and click OK. (screenshot)
13. Open Explorer and navigate to "C:\Windows\System32\inetsrv" find Metabase.xml file and before modifying it make a backup copy.
14. Open Metabase.xml in text editor and find string:
Location ="/LM/W3SVC/Filters/Compression/gzip"
15. Config values to suit your needs:

HcDoDynamicCompression="TRUE" (to enable compression of dynamic content)
HcDoOnDemandCompression="TRUE" (to enable compression of static files that are not compressed yet)
HcDoStaticCompression="TRUE" (to enable compression of static content)
HcDynamicCompressionLevel="10" (level of dynamic compression. Higher level equals better compression rate, but requires more CPU resources)
HcFileExtensions="htm
html
txt"
(file types to include in static compression, one per line)
HcOnDemandCompLevel="10" (level of OnDemandCompression)
HcPriority="1"
HcScriptFileExtensions="asp
dll
aspx
cs
exe
pdf"
(file types to include in dynamic compression, one per line)

16. Save and close Metabase.xml and restart IIS server by right clicking your server node in IIS Manager and choosing All Tasks->Restart IIS... (screenshot)
17. Check if compression is working
go to http://www.seoconsultants.com/tools/compression.asp enter your URL and press the Check Compression button. If your site is compressed you'll see Compression status: Compressed (gzip). (screenshot)

Now you might want to disable compression for some sites, to do this you need to run the following command in the command prompt:

adsutil set w3svc/1690634459/DoDynamicDompression false


Or if you want to disable compression on specific folder or file in the site you would type this:

adsutil set w3svc/1690634459/root/forum/DoDynamicCompression false


Replace 1690634459 with the ID of your website which can be found in IIS Manager, Web Sites node "Identifier" column.
If you want to disable Static Compression for specific site replace "DoDynamicCompression" with "DoStaticCompression".

If you want disable compression for All sites but one, you can do this in the following way:
First disable compression for all sites by running command in the command prompt:
adsutil set w3svc/filters/compression/parameters/HcDoStaticCompression false

Then enable compression for one or multiple sites of your choice:
adsutil set w3svc/1690634459/DoStaticCompression true

Links:
http://www.dotnetjunkies.com/Article/16267D49-4C6E-4063-AB12-853761D31E66.dcik
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/502ef631-3695-4616-b268-cbe7cf1351ce.mspx?mfr=true

No comments:

Post a Comment