Click here to Skip to main content
15,879,474 members
Articles / Web Development / IIS
Tip/Trick

Enable Http Compression

Rate me:
Please Sign up or sign in to vote.
4.33/5 (6 votes)
18 May 2010CPOL 16K   4   3
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) RadixWeb India
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralIIS 7 Performance Section Pin
TheyCallMeMrJames18-May-10 3:47
TheyCallMeMrJames18-May-10 3:47 
GeneralRe: IIS 7 Performance Section Pin
Tripathi Swati18-May-10 22:30
Tripathi Swati18-May-10 22:30 
GeneralRe: IIS 7 Performance Section Pin
TheyCallMeMrJames19-May-10 3:01
TheyCallMeMrJames19-May-10 3:01 

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

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