Loading...

.htaccess 使用gzip壓縮網站加快加載速度並節省頻寬

Temperature: 0 °C

Mark ChangMark Chang
author_tools

mod_gzipUrl link是Apache的外部擴展模組,可以將文件發送到客戶端之前快速輕鬆地對其進行壓縮。

如果您的託管服務提供商已啟用mod_gzip模塊,則壓縮內容的最佳方法是在.htaccess文件中添加以下幾行:

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

如果網站空間商沒有啟用此模塊?

則可以添加以下:
php_value output_handler ob_gzhandler

這可以讓PHP可以壓縮您的PHP文件(但請謹慎使用,因為這會佔用大量CPU)。

以上資訊紀錄~

#故事  #htaccess  #gzip  #Apache  #壓縮網站  #節省頻寬  
https://innstory.com/story-htaccess_使用gzip壓縮網站加快加載速度並節省頻寬-2712
apache

Prev
 PHP如何移除_xpoweredby_資訊

Next
使用htaccess中更改sessionname 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

ajax錯誤訊息提示

ajax錯誤訊息提示

pexelsphoto55 ajax目前已經是我寫系統使用非常普遍的方式~ 雖說常寫,但偶爾還是會有...

改變input placeholder 字體顏色

改變input placeh...

colorphoto55 通常我們會使用 placeholder 來作為欄位提醒文字~ 通常 pla...

要如何知道ajax執行失敗原因?

要如何知道ajax執行失敗原...

只要在error的function 更改為以下寫法即可: error: function (XMLH...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format