Windows XP Windows 7 Windows 2003 Windows Vista Windows教程綜合 Linux 系統教程
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟件教程
 Windows教程網 >> 電腦軟件教程 >> 服務器技術 >> 關於服務器 >> IIS6.0配置使用GZip壓縮頁面文件(絕對生效)

IIS6.0配置使用GZip壓縮頁面文件(絕對生效)

日期:2017/2/8 10:20:13      編輯:關於服務器
使用GZip壓縮頁面文件,既可以降低站點流量,減輕服務器負擔,又可以提高用戶打開頁面的速度,是非常有優勢的。今天我們看看怎麼在IIS6.0中配置使用GZip壓縮。

3步開啟IIS6.0GZip壓縮功能

①在IIS中打開網站屬性,切換到"服務"選項卡,鉤選"壓縮應用程序文件"和"壓縮靜態文件":
②右鍵點擊"Web 服務擴展",選擇"添加一個新的 Web 服務擴展",設置如下:
③在命令行下執行"iisreset /restart",重啟IIS服務,這樣就可以了;

配置啟用GZip壓縮的文件類型

①在命令行下執行"iisreset /stop",停止IIS服務(開啟狀態下MetaBase.xml只讀);
②打開C:\WINDOWS\system32\inetsrv\MetaBase.xml,找到: <IIsCompressionScheme     Location ="/LM/W3SVC/Filters/Compression/gzip"
         HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
         HcCreateFlags="1"
         HcDoDynamicCompression="TRUE"
         HcDoOnDemandCompression="TRUE"
         HcDoStaticCompression="TRUE"
         HcDynamicCompressionLevel="0"
         HcFileExtensions="htm
             html
             txt"
         HcOnDemandCompLevel="10"
         HcPriority="1"
         HcScriptFileExtensions="asp
             dll
             exe"
     >
</IIsCompressionScheme>


HcFileExtensions屬性為要啟用GZip壓縮的靜態文件擴展名,HcScriptFileExtensions屬性為要啟用GZip壓縮的動態文件擴展名,可根據需要進行設置後保存;
③在命令行下執行"iisreset /start",開啟IIS服務;

電腦軟硬件應用網站長PS:如果以上手動設置你不會,或者設置後不能生效。建議使用以下CMD自動設置(將以下代碼使用記事本另存為IIS6-SET-GZIP.cmd,放到C:\Inetpub\AdminScripts下運行即可):

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
cscript adsutil.vbs set W3SVC/Filters/Compression/Parameters/HcMaxQueueLength 1000
cscript adsutil.vbs set W3SVC/Filters/Compression/Parameters/HcMinFileSizeForComp 1
cscript adsutil.vbs set W3SVC/Filters/Compression/Parameters/HcNoCompressionForHttp10 FALSE
cscript adsutil.vbs set W3SVC/Filters/Compression/Parameters/HcNoCompressionForProxies FALSE
cscript adsutil.vbs set W3SVC/Filters/Compression/Parameters/HcNoCompressionForRange FALSE
cscript adsutil.vbs set W3SVC/Filters/Compression/Parameters/HcSendCacheHeaders FALSE

iisreset

Copyright © Windows教程網 All Rights Reserved