IIS啟用GZIP壓縮js、css無效的原因及解決方法
在卡卡網(wǎng)的網(wǎng)站速度診斷里的檢測(cè)結(jié)果:
html網(wǎng)頁已經(jīng)成功啟用了GZip壓縮
css文件未成功啟用GZip壓縮
后來研究發(fā)現(xiàn),IIS啟用GZip時(shí)默認(rèn)壓縮的只有html網(wǎng)頁,如果需要壓縮css、js等文件,還需要另外簡(jiǎn)單配置一個(gè)文件。
打開C:\WINDOWS\system32\inetsrv\MetaBase.xml這個(gè)文件,然后查找“IIsCompressionScheme”,會(huì)發(fā)現(xiàn)有三段,后面那個(gè)不用管,只設(shè)置前面兩個(gè)即可。其中,"/LM/W3SVC/Filters/Compression/gzip"用于設(shè)置gzip壓縮,"/LM/W3SVC/Filters/Compression/deflate"用于設(shè)置deflate壓縮。
如需壓縮靜態(tài)文件,則將HcDoStaticCompression和HcDoOnDemandCompression設(shè)置為“TRUE”,并在HcFileExtensions的屬性中加入需要壓縮的靜態(tài)文件:css、js等;
如需壓縮動(dòng)態(tài)文件,則將HcDoDynamicCompression設(shè)置為“TRUE”,并在HcScriptFileExtensions屬性中加入需要壓縮的動(dòng)態(tài)文件:aspx、php等。
另外,HcDynamicCompressionLevel屬性和HcOnDemandCompLevel屬性一般都推薦設(shè)置為9, 具有最佳性價(jià)比。
參考如下各參數(shù)設(shè)置:
<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/deflate"
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="0"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="9"
HcFileExtensions="htm
html
txt
css
js
xml"
HcOnDemandCompLevel="9"
HcPriority="1"
HcScriptFileExtensions="asp
aspx
dll
exe"
>
</IIsCompressionScheme>
<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/gzip"
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="1"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="9"
HcFileExtensions="htm
html
txt
css
js
xml"
HcOnDemandCompLevel="9"
HcPriority="1"
HcScriptFileExtensions="asp
aspx
dll
exe"
>
</IIsCompressionScheme>
設(shè)置完畢后,重新啟動(dòng)IIS,再檢測(cè)時(shí)發(fā)現(xiàn)css、js等文件已經(jīng)成功啟用GZip了。
您可能對(duì)如下文章也感興趣
相關(guān)文章
Windows Server 2012 Iis8 php環(huán)境配置方法
最近微軟推出了win2012服務(wù)器操作系統(tǒng),是不是速度快了點(diǎn),win2008還沒推出歷史舞臺(tái),win2008還沒學(xué)會(huì)使用呢,有空可以把系統(tǒng)效率提高點(diǎn)秒殺linux吧2013-09-09IIS提示Server Application Error的解決方法集錦
The server has encountered an error while loading an application during the processing of your request. Please refer to the event log for more detail information. Please contact the server administrator for assistance.2011-01-01IIS下防止mdb數(shù)據(jù)庫被下載的實(shí)現(xiàn)方法
很多網(wǎng)站都是使用的是asp+access數(shù)據(jù)庫,但經(jīng)常不改默認(rèn)的mdb地址等其它原因,數(shù)據(jù)庫很容易就被別人下載了,損失了很多寶貴的數(shù)據(jù)。2010-12-12Windows 2008 R2下如何進(jìn)行Wincache安裝與配置教程
這篇文章主要介紹了Windows 2008 R2下如何進(jìn)行Wincache安裝與配置教程,需要的朋友可以參考下2016-06-06IIS站點(diǎn)提示403?-?Forbidden:Access?is?denied問題的解決方法
在使用IIS的時(shí)候如果遇到403相關(guān)的錯(cuò)誤,往往束手無策,不知道是什么權(quán)限的原因,現(xiàn)總結(jié)如下,這篇文章主要給大家介紹了關(guān)于IIS站點(diǎn)提示403?-?Forbidden:Access?is?denied問題的解決方法,需要的朋友可以參考下2023-10-10Windows服務(wù)器系統(tǒng)服務(wù)端口對(duì)照表
這篇文章主要介紹了Windows服務(wù)器系統(tǒng)服務(wù)端口對(duì)照表,需要的朋友可以參考下2014-03-03批處理自動(dòng)解決Imail的Queuemgr服務(wù)掛起的方法
批處理自動(dòng)解決Imail的Queuemgr服務(wù)掛起的方法...2007-10-10在windows?server?2012?r2中安裝mysql的詳細(xì)步驟
這篇文章主要介紹了在windows?server?2012?r2中安裝mysql的詳細(xì)步驟,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-07-07服務(wù)器大量php-cgi.exe進(jìn)程導(dǎo)致CPU占用100%的解決方法
這篇文章主要介紹了服務(wù)器大量php-cgi.exe進(jìn)程導(dǎo)致CPU占用100%的解決方法,一般就是增加配置或者就是檢查tmp目錄有沒有大量文件導(dǎo)致服務(wù)器變慢2021-06-06