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

Enable Http Compression

By , 18 May 2010
 
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)

About the Author

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

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralIIS 7 Performance SectionmemberTheyCallMeMrJames18-May-10 3:47 
GeneralRe: IIS 7 Performance SectionmemberTripathi Swati18-May-10 22:30 
Thanks James for giving your valuable input in this tip ...
Reasons are not Important but Results are Important.
http://www.sql4professional.blogspot.com
Swati Tripathi

GeneralRe: IIS 7 Performance SectionmemberTheyCallMeMrJames19-May-10 3:01 

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

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