使用Gzip壓縮會增大服務器CPU的使用率但可以通過壓縮而減少服務器向客戶端發送的數據,若使用了Gzip壓縮IIS在向客戶端發送數據時會自動檢測,如果客戶端浏覽器支持IE6.0,firefox Gzip,則使用Gzip壓縮後再傳送數據,如果不支持,則使用常規方式發送。
所以,總結下他的優缺點,優:壓縮傳輸,速度一般提高2倍。缺:CPU占用會有所提高,不過通過我的一點分析,GZIP只是在訪問一個頁時才會進行壓縮,下次如果網頁沒有變動是不會壓縮的,除非是使用壓縮動態文件,這得實時的去壓縮。
REM Setup IIsCompressionScheme for deflate cscript adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcCompressionDll "%windir%\system32\inetsrv\gzip.dll" cscript adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcCreateFlags 0 cscript adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcDoDynamicCompression TRUE cscript adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcDoOnDemandCompression TRUE cscript adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcDoStaticCompression TRUE cscript adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcDynamicCompressionLevel 9 cscript adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcFileExtensions "htm" "html" "txt" "js" "xml" "css" cscript adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcOnDemandCompLevel 9 cscript adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcPriority 1 cscript adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx" REM Setup IIsCompressionScheme for GZip cscript adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcCompressionDll "%windir%\system32\inetsrv\gzip.dll" cscript adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcCreateFlags 1 cscript adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcDoDynamicCompression TRUE cscript adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcDoOnDemandCompression TRUE cscript adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcDoStaticCompression TRUE cscript adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcDynamicCompressionLevel 9 cscript adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcFileExtensions "htm" "html" "txt" "js" "xml" "css" cscript adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcOnDemandCompLevel 9 cscript adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcPriority 1 cscript adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx" REM Setup IIsCompressionSchemes parameters cscript adsutil.vbs set W3SVC/Filters/Compression/Parameters/HcCacheControlHeader max-age=86400 cscript adsutil.vbs set W3SVC/Filters/Compression/Parameters/HcCompressionBufferSize 102400 cscript adsutil.vbs set W3SVC/Filters/Compression/Parameters/HcCompressionDirectory "%windir%\IIS Temporary Compressed Files" cscript adsutil.vbs set W3SVC/Filters/Compression/Parameters/HcDoDiskSpaceLimiting FALSE cscript adsutil.vbs set W3SVC/Filters/Compression/Parameters/HcDoDynamicCompression TRUE cscript adsutil.vbs set W3SVC/Filters/Compression/Parameters/HcDoOnDemandCompression TRUE cscript adsutil.vbs set W3SVC/Filters/Compression/Parameters/HcDoStaticCompression TRUE cscript adsutil.vbs set W3SVC/Filters/Compression/Parameters/HcExpiresHeader "Wed, 01 Jan 1997 12:00:00 GMT" cscript adsutil.vbs set W3SVC/Filters/Compression/Parameters/HcFilesDeletedPerDiskFree 256 cscript adsutil.vbs set W3SVC/Filters/Compression/Parameters/HcIoBufferSize 102400 cscript adsutil.vbs set W3SVC/Filters/Compression/Parameters/HcMaxDiskSpaceUsage 0
以上是方法,保存做一個批處理命令文件即可。格式如:adsutil.vbs