右擊"網(wǎng)站"->"屬性",選擇"服務"。在"HTTP壓縮"框中選中"壓縮應用程序文件"和" 壓縮靜態(tài)文件",按需要設置"臨時目錄"和"臨時目錄的最大限制";
第三步:修改MetaBase.xml
開始 > 運行中輸入 c:\windows\system32\inetsrv,找到 MeteBase.xml,先備份,在修改。(有的服務器不需要修改此文件便可以使用)
搜索 Location ="/LM/W3SVC/Filters/Compression/gzip"
仔細核對下代碼:
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="0"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="FALSE"
HcDynamicCompressionLevel="0"
HcFileExtensions="htm
html
txt"
HcOnDemandCompLevel="10"
HcPriority="1"
HcScriptFileExtensions="asp
dll
exe"
>
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"
>
替換成:
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="1"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="10"
HcFileExtensions="html
css
js
htm
xml
txt"
HcOnDemandCompLevel="10"
HcPriority="1"
HcScriptFileExtensions="php
dll"
>
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="2"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="10"
HcFileExtensions="html
css
js
htm
xml
txt"
HcOnDemandCompLevel="10"
HcPriority="1"
HcScriptFileExtensions="php
dll"
>
修改好后,在服務中停止IIS Admin Service 服務。
然后在保存MeteBase.xml,保存好后再啟動IIS。這樣Gzip壓縮就啟用成功了。
最后,測試Gzip壓縮是否成功,可以到站長工具網(wǎng)站上的Gzip進行檢測。