【IIS6.0的設定】

1. 開啟Internet 服務管理員–>網站–>內容–>服務。在 HTTP壓縮框中勾選 "壓縮應用程式檔(Compress application files)" 和 "壓縮靜態檔案(Compress static files)"

2. 接下來配置 GZip 元件,在網際網路資訊服務(IIS)管理員,點擊網頁服務延伸–>增加一個新的網頁服務延伸,在 "新增網頁服務延伸" 框中輸入延伸名稱 "IIS Compression",選擇"需要的檔案" 為 C:\WINDOWS\system32\inetsrv\gzip.dll,並設定為 "允許",若無啟動此功能,則所設定之參數並不會產生效用

3. 停用IIS相關服務,與IIS執行相關的服務共有三個HTTP SSL、IIS Admin、World Wide Web Publishing,請將這三個服務都停止。

4. 打開 C:\Windows\System32\inetsrv\MetaBase.xml,在修改前請先備份(切記),這個檔案很大,找到下面一段內容:

<IIsCompressionScheme Location="/LM/W3SVC/Filters/Compression/deflate"
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="0"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="FALSE"
HcDynamicCompressionLevel="0"
HcFileExtensions="htm html txt"
HcOnDemandCompLevel="0"
HcPriority="1"
HcScriptFileExtensions="asp dll exe" />
===========================================================
<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="0"
HcPriority="1"
HcScriptFileExtensions="asp dll exe" />

 

各參數所代表的意義

 

HcDoDynamicCompression:是否壓縮動態檔 HcDoStaticCompression、HcDoOnDemandCompression:是否壓縮靜態檔 HcDynamicCompressionLevel、HcOnDemandCompLevel:表示需要的壓縮率,數位越小壓縮率越低 HcScriptFileExtensions:要壓縮的動態檔副檔名 HcFileExtensions:要壓縮的靜態檔副檔名

 

找到以上的資訊後,請分別將兩段的屬性更改為:

HcDynamicCompressionLevel="10" HcFileExtensions="htm html txt css js " HcScriptFileExtensions="asp dll exe aspx"


5. 儲存 C:\Windows\System32\inetsrv\MetaBase.xml,如果發生無法存檔的問題,請檢查前一步驟中是否有正確的將三個服務停止。

6. 重新開機步驟3中停用的三個服務。

7. 開啟系統進行測試。



【IIS7.0的設定】


1.找到IIS–>Compression

2.設定壓縮細節

Enable dynamic content compression:壓縮動態檔案如aspx、asp等... Enable static content compression:壓縮靜態檔案如htm、js、css等... Only compress files larger than(in bytes):只有在檔案超過多大時才壓縮... Per application pool disk space limit(in MB):壓縮後的檔案會被cache住,設定其cache的最大容量...


網頁壓縮的設定在IIS7.0預設是啟用的,而且設定起來比IIS6.0簡單很多,而既然微軟敢將此功能作為預設值,我想也是對其架構有一定的把握度吧。

arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()