March 26, 2005

310 words 2 mins read

Howto: Enable Compression on IIS6.0

Now there are alot of articles about how to enable compression on IIS 6.0, but I thought I’d write my own because I seem to be doign this more often — and forgetting how to everytime. I also find that using the UI is a bit iffy, sometimes I have the tab they want me to modify on screen, sometimes I dont (hell one server even told me the module running that tab was out of date, what ever). Hopefully these instructions should help you get along in setting this up (Note: I’m enabling compression on scripts like aspx for a webapp, I dont need compression on static content — But its XML and should be easy enough to figure out).

First things first, open management console, open IIS, open “Web Site Extensions”. Right click, “Add a new Webservice Extention”. Extension name can be what ever, I use “HTTP/Gzip Compression”. Click Add. Put in: C:\WINDOWS\system32\inetsrv\gzip.dll. Ok. Ok. Click on the name of that extension you just added, click “Allow” on the left side.

Next section, right click on IIS, click properties. Select “Enable Direct Metabase Edit”. Hit Apply, Ok.

Time to edit the metabase.xml file, as usual back your sh$t up before you do this. Open the metabase.xml file: c:\WINDOWS\system32\metabase.xml — Search for ‘<IISCompressionScheme’ — Below I’ve included the important section from my metabase file with bold indicating modified or added files:

<IIsCompressionScheme	Location ="/LM/W3SVC/Filters/Compression/deflate"
		HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
		HcCreateFlags="0"
		HcDoDynamicCompression="TRUE"
		HcDoOnDemandCompression="TRUE"
		HcDoStaticCompression="FALSE"
		HcDynamicCompressionLevel="8"
		HcFileExtensions="htm
			html
			txt"
		HcOnDemandCompLevel="9"
		HcPriority="1"
		HcScriptFileExtensions="asp
			dll
			exe
			aspx"
	>
</IIsCompressionScheme>
<IIsCompressionScheme	Location ="/LM/W3SVC/Filters/Compression/gzip"
		HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
		HcCreateFlags="1"
		HcDoDynamicCompression="TRUE"
		HcDoOnDemandCompression="TRUE"
		HcDoStaticCompression="FALSE"
		HcDynamicCompressionLevel="8"
		HcFileExtensions="htm
			html
			txt"
		HcOnDemandCompLevel="9"
		HcPriority="1"
		HcScriptFileExtensions="asp
			dll
			exe
			aspx"
	>
</IIsCompressionScheme>
<IIsCompressionSchemes	Location ="/LM/W3SVC/Filters/Compression/Parameters"
		HcCacheControlHeader="max-age=86400"
		HcCompressionBufferSize="8192"
		HcCompressionDirectory="%windir%\IIS Temporary Compressed Files"
		HcDoDiskSpaceLimiting="FALSE"
		HcDoDynamicCompression="TRUE"
		HcDoOnDemandCompression="TRUE"
		HcDoStaticCompression="FALSE"
		HcExpiresHeader="Wed, 01 Jan 1997 12:00:00 GMT"
		HcFilesDeletedPerDiskFree="256"
		HcIoBufferSize="8192"
		HcMaxDiskSpaceUsage="100000000"
		HcMaxQueueLength="1000"
		HcMinFileSizeForComp="1"
		HcNoCompressionForHttp10="TRUE"
		HcNoCompressionForProxies="TRUE"
		HcNoCompressionForRange="FALSE"
		HcSendCacheHeaders="FALSE"
	>
</IIsCompressionSchemes>

Restart IIS — And you should be set.