Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Enable Http Compression

0.00/5 (No votes)
18 May 2010 2  
A set of command line operations to enable and configure compression in IIS.
You can use compression in IIS to improve the response of your web site.

There are two implemented methods for compression:

    • Deflate

    • GZIP



Navigate to the AdminScripts directory in a command prompt window with administrative privileges. The default script host is wscript. For the purpose of this tip, switch to cscript with the following command

cscript.exe /h:cscript


The following commands will change various compression settings for IIS.

cscript.exe adsutil.vbs set W3svc/Filters/Compression/{GZIP|DEFLATE}/
{HcFileExtensions "StaticFileType" ...}|{HcScriptFileExtensions "DynamicFileType" ...}


Configure static compression


CSCRIPT.EXE C:\Inetpub\AdminScripts\ADSUTIL.VBS SET W3SVC/Filters/Compression/Parameters/HcDoStaticCompression TRUE

CSCRIPT.EXE C:\Inetpub\AdminScripts\ADSUTIL.VBS SET W3Svc/Filters/Compression/GZIP/HcFileExtensions "htm" "html" "js" "txt"

CSCRIPT.EXE C:\Inetpub\AdminScripts\ADSUTIL.VBS SET W3Svc/Filters/Compression/DEFLATE/HcFileExtensions "htm" "html" "js" "txt"


Configure dynamic file compression


CSCRIPT.EXE C:\Inetpub\AdminScripts\ADSUTIL.VBS SET W3SVC/Filters/Compression/Parameters/HcDoDynamicCompression TRUE

CSCRIPT.EXE C:\Inetpub\AdminScripts\ADSUTIL.VBS SET W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions "asp" "asmx" "aspx"
CSCRIPT.EXE C:\Inetpub\AdminScripts\ADSUTIL.VBS SET W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions "asp" "asmx" "aspx"


Set the compression level


CSCRIPT.EXE C:\Inetpub\AdminScripts\ADSUTIL.VBS SET W3Svc/Filters/Compression/GZIP/HcDynamicCompressionLevel "9"
CSCRIPT.EXE C:\Inetpub\AdminScripts\ADSUTIL.VBS SET W3Svc/Filters/Compression/DEFLATE/HcDynamicCompressionLevel "9"


Global compression settings


cscript.exe C:\Inetpub\AdminScripts\adsutil.vbs set w3svc/root/DoStaticCompression False
cscript.exe C:\Inetpub\AdminScripts\adsutil.vbs set w3svc/root/DoDynamicCompression False

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here