HTTP COMPRESSION HTTP 壓縮實現 (iis6)(翻譯自微軟知識庫文章)

來源:互聯網
上載者:User

You can enable HTTP compression server-wide or on a specific directory. HTTP compression improves bandwidth utilization and speeds up Web site performance. In addition, you can compress static or dynamic responses.

你可以啟用HTTP伺服器端壓縮,它可以提高你的頻寬利用率,加速你的網站效能。另外,你也可以選擇是壓縮動態還是靜態響應包。

有一點你不能忽略的是:以下的所有操作必須在具有管理員權限的帳號下操作。

 

操作步驟:

1 點擊iis,網站,屬性,服務,選擇壓縮應用程式(啟用壓縮動態檔案),選擇複選框,壓縮靜態檔案夾的位置。這裡有幾點要說明一下:啟用壓縮動態檔案,就是壓縮的比如aspx,asp等動態檔案,但是每次壓縮都是即時的,所以對伺服器的cpu佔用是非常大的。推薦不選。壓縮靜態檔案,iis只需要壓縮靜態檔案一次,就儲存在剛才指定的那個檔案夾裡面。Once a static file is compressed, it is cached in this temporary directory until it expires, or the content changes. The directory must be on the local drive of an NTFS–formatted partition.一旦靜態檔案壓縮了,它就被緩衝在臨時檔案夾裡,直到它到期,內容改變。還有就是這個檔案夾的所在的磁碟,必須是以NTFS格式的磁碟。

 

Under Maximum temporary directory size, click a folder size option. If you specify a maximum size under Limited to (in megabytes) (the default setting is 95 MB), then when the limit is reached, IIS automatically cleans up the temporary directory by applying the "least recently used" rule.

如果指定了最大的檔案大小,那麼如果一旦達到最大容量,那麼iis就會自動地清除臨時檔案夾的東西,清楚原則是least recently used" rule,最近使用地最少的就清除掉。

 

To enable global HTTP compression by using Adsutil.vbs

 

 1.  Open a command prompt.

 

2.  To enable dynamic compression, type the following at the command prompt and then press ENTER:

 

cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoDynamicCompression true

 

3.  To enable static compression, type the following at the command prompt and then press ENTER:

 

cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoStaticCompression true

 

 

要啟用全域的HTTP壓縮,請使用ADSUTIL.Vbs.這種我並不是很推薦,也不喜歡。

1 開啟命令視窗,

2 如果開啟動態壓縮,鍵入以下的命令參數,按斷行符號:

cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoDynamicCompression true

3 啟用靜態壓縮,鍵入以下命令,按斷行符號:

cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoStaticCompression true

 

 

 

To enable HTTP Compression for Individual Sites and Site Elements

為單獨網站或者網站元素提供HTTP壓縮,請操作如下步驟:

 1.  To enable static compression for only a single directory, first disable global static compression (if it is enabled) and then enable static compression at that directory. For example, to enable static compression for a directory at http://www.contoso.com/Home/StyleSheets, perform the following steps:

1 啟用單一的靜態壓縮檔夾,首先檢查你是不是啟用了全域的靜態壓縮,如果啟用就要關閉它,接下來啟用靜態壓縮一個檔案夾。例如:下面的例子是啟用http://www.contoso.com/Home/StyleSheets 這個檔案夾的靜態壓縮,請按照下列步驟進行:

1.

 Disable global static compression by executing the following command at a command prompt:

 

1 禁止全域壓縮,通過命令提示中輸入下列命令,

adsutil set w3svc/filters/compression/parameters/HcDoStaticCompression false

 

1.

 Enable static compression at this directory by executing the following command at a command prompt:

 啟用靜態壓縮一個檔案夾,執行以下的命令,在命令視窗中:

 

adsutil set w3svc/1/root/Home/StyleSheets/DoStaticCompression true

 

2.  To disable static compression for only a single directory, first enable global static compression (if it is disabled) and then disable static compression at that directory. For example, to enable static compression for a directory at http://www.contoso.com/Home/StyleSheets, perform the following steps:

2 要禁止為一個檔案夾的靜態壓縮,第一步就是要啟用全域的靜態壓縮,然後禁止掉為一個檔案的靜態壓縮,請執行下列步驟:

1.

 Disable global static compression by executing the following command at a command prompt:

 1 禁止全域靜態檔案壓縮,執行下列的命令:

 

adsutil set w3svc/filters/compression/parameters/HcDoStaticCompression true

 

1.

 Enable static compression at this directory by executing the following command at a command prompt:

 

啟用靜態壓縮一個檔案夾,執行下列的命令:

adsutil set w3svc/1/root/Home/StyleSheets/DoStaticCompression false

 

 

 

以上都是基於iis6的。微軟提供的這些都是基於命令視窗的操作,當然也可以可視化操作,直接在iis中啟用了壓縮,並且在C:\WINDOWS\system32\inetsrv目錄中添加伺服器擴充gzip.dll(iis伺服器擴充) 後,再開啟這個檔案夾下的檔案: C:\Windows\System32\inetsrv\MetaBase.xml,開啟後尋找Filters/Compression/gzip (這個檔案就是iis的設定檔)在這個節點下,有

HcDoDynamicCompression,HcDoOnDemandCompression,HcDoStaticCompression,如果你要設定動態檔案壓縮,則啟用第一個,設定為true,建議不要啟用。如果要啟用靜態檔案壓縮,請設定後2個為true,然後指定他們各自的壓縮程度: CompressionLevel,這個我的指定是100,然後指定壓縮的靜態檔案的尾碼名類型,我指定的是css,js,xml .指定完後需要停止iis服務,在windows服務中停止。停止後儲存。然後你就可以到fiddler中觀察到你的一些檔案被壓縮了。
我在我們網站的壓縮應用,使得我的一個200KB的JS檔案壓縮成了20KB!!!效率非常高的!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.