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

使用jQuery阻止input直接按Enter就送出表單

使用jQuery阻止inpu...

使用表單是傳送資料裡經常會用到的方式。 這時當使用者輸入表單後習慣上按下Enter,則會將表單內容送...

Android UI設計距離課題

Android UI設計距離...

layoutmarginTop指定該屬性所在控件距離上方的位置空間。 layoutmarginBot...

jQuery resize取得瀏覽器目前視窗寬度

jQuery resize取...

pexelsphotokeyboard5 在使用CSS調整RWD顯示時~ 也可以使用javascri...

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