IIS7.5開啟GZip壓縮,同時啟用GZip壓縮JS/CSS檔案的設定方法[bubuko.com]

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   os   使用   java   ar   

IIS7.5或者IIS7.0開啟GZip壓縮方法:開啟IIS,在右側點擊某個網站,在功能視圖中的“IIS”地區,雙擊進入“壓縮
”,

分別勾選“啟用動態內容壓縮”和“啟用靜態內容壓縮”。這樣最通用的設定GZip壓縮就完成了。

靜態內容壓縮和動態內容壓縮的區別
靜態內容壓縮:壓縮的靜態響應可以緩衝到磁碟上,供多個請求使用,同時不會降低 CPU 資源的效能。對於下一個請求
,可以從磁碟檢索壓縮檔,由於 CPU 不必再次壓縮檔,從而提高了效能。 
動態內容壓縮:壓縮Live App程式響應會影響 CPU 資源,因為 IIS 不緩衝動態輸出的壓縮版本。如果對動態響應啟用
了壓縮,那麼當 IIS 每次收到對包含動態內容的資源的請求時,都會發送新壓縮的響應。因為動態壓縮會消耗大量的 
CPU 時間和記憶體資源,所以應當僅在滿足下列條件的伺服器上使用它:用戶端的網路連接速度很慢,但有多餘的 CPU 時
間。
啟用了IIS的動態和靜態內容壓縮後預設只壓縮尾碼是htm與html的檔案,對於js、css並沒有壓縮。對js、css檔案有沒
有壓縮效果可以通過一些線上的測試載入器查看。
如何讓GZip壓縮支援js、css檔案呢?需要做進一步的設定。
開啟C:\Windows\System32\inetsrv\config\applicationhost.config,找到以下內容:

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">    <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />    <dynamicTypes>        <add mimeType="text/*" enabled="true" />        <add mimeType="message/*" enabled="true" />        <add mimeType="*/*" enabled="false" />    </dynamicTypes>    <staticTypes>        <add mimeType="text/*" enabled="true" />        <add mimeType="message/*" enabled="true" />        <add mimeType="application/x-javascript" enabled="true" />        <add mimeType="application/atom+xml" enabled="true" />        <add mimeType="application/xaml+xml" enabled="true" />        <add mimeType="*/*" enabled="false" />    </staticTypes></httpCompression>

將dynamicTypes下的“<add mimeType="application/x-javascript" enabled="true" />”剪下到“staticTypes”下。 可根據實際情況添加自己需要的mime節點。

原文:http://bubuko.com/infodetail-377441.html

IIS7.5開啟GZip壓縮,同時啟用GZip壓縮JS/CSS檔案的設定方法[bubuko.com]

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.