合肥市高新區(qū)長江西路與科學大道交口5F創(chuàng)業(yè)園A座309
136 5560 1775

如何在vps或服務(wù)器上設(shè)置啟用Gzip壓縮提高瀏覽速度

發(fā)表日期:2013-10-16 瀏覽次數(shù):4225次

我在用站長工具查看網(wǎng)站的網(wǎng)站的壓縮檢測的時候,一般會出現(xiàn)兩種情況,一種是已經(jīng)壓縮,類似以下這樣的,還有一種就是沒有壓縮。

那么啟用這種壓縮有什么好處呢,它的好處顯而易見,提高網(wǎng)頁瀏覽速度,無論是之前說的精簡代碼、壓縮圖片都不如啟用Gzip來的實在。Gzip壓縮效率非常高,通??梢赃_到70%的壓縮率,也就是說,如果你的網(wǎng)頁有30K,壓縮之后就變成了9K左右。那么很多的vps或服務(wù)器都沒有啟用,如果來啟用這個服務(wù)呢,下面合肥網(wǎng)站建設(shè)服務(wù)商啟邁科技和大家一起說一下。

第一步:打開IIS,啟用HTTP壓縮服務(wù)

 

右擊“網(wǎng)站”->“屬性”,選擇“服務(wù)”。在“HTTP壓縮”框中選中“壓縮應(yīng)用程序文件”和“ 壓縮靜態(tài)文件”,按需要設(shè)置“臨時目錄”和“臨時目錄的最大限制”;

 

第二步:啟用web服務(wù)

 

第三步:修改MetaBase.xml

開始 > 運行中輸入 c:windowssystem32inetsrv,找到 MeteBase.xml,先備份,在修改。(有的服務(wù)器不需要修改此文件便可以使用)

搜索 Location ="/LM/W3SVC/Filters/Compression/gzip"

仔細核對下代碼:

<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/deflate"
HcCompressionDll="%windir%system32inetsrvgzip.dll"
HcCreateFlags="0"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="FALSE"
HcDynamicCompressionLevel="0"
HcFileExtensions="htm
html
txt"
HcOnDemandCompLevel="10"
HcPriority="1"
HcScriptFileExtensions="asp
dll
exe"
>
</IIsCompressionScheme>
<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/gzip"
HcCompressionDll="%windir%system32inetsrvgzip.dll"
HcCreateFlags="1"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="0"
HcFileExtensions="htm
html
txt"
HcOnDemandCompLevel="10"
HcPriority="1"
HcScriptFileExtensions="asp
dll
exe"
>
</IIsCompressionScheme>
替換成:

<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/gzip"
HcCompressionDll="%windir%system32inetsrvgzip.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"
>
</IIsCompressionScheme>
<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/deflate"
HcCompressionDll="%windir%system32inetsrvgzip.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"
>
</IIsCompressionScheme>
修改好以后,重啟iis

然后在保存MeteBase.xml,保存好后再啟動IIS。這樣Gzip壓縮就啟用成功了。

最后,測試Gzip壓縮是否成功,可以到站長工具網(wǎng)站進行查詢。rlfp.cn 就是這樣操作的。


將文章分享到:

版權(quán)所有:啟邁科技-合肥網(wǎng)站建設(shè) 皖I(lǐng)CP備19009304號-1 皖公網(wǎng)安備 34010402702162號

網(wǎng)站建設(shè),網(wǎng)站設(shè)計公司啟邁科技,為眾多企業(yè)提供網(wǎng)站建設(shè),網(wǎng)站制作,響應(yīng)式網(wǎng)站設(shè)計,手機網(wǎng)站建設(shè),微網(wǎng)站,模板建站,企業(yè)郵箱等一站式互聯(lián)網(wǎng)解決方案和建站服務(wù)10年。