Click here to Skip to main content
Click here to Skip to main content

Tagged as

Enable Http Compression

, 18 May 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
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


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Tripathi Swati
Software Developer (Senior) RadixWeb India
India India
No Biography provided

Comments and Discussions

GeneralIIS 7 Performance Section PinmemberTheyCallMeMrJames18-May-10 4:47 
GeneralRe: IIS 7 Performance Section PinmemberTripathi Swati18-May-10 23:30 
Thanks James for giving your valuable input in this tip ...
Reasons are not Important but Results are Important.
Swati Tripathi

GeneralRe: IIS 7 Performance Section PinmemberTheyCallMeMrJames19-May-10 4:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150331.1 | Last Updated 18 May 2010
Article Copyright 2010 by Tripathi Swati
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid