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

解決iphone 不能使用colorbox 滑動的方式

解決iphone 不能使用c...

pexelsphotoiphone #cboxLoadedContent, #cboxContent...

修改php.ini更改允許上傳檔案的大小

修改php.ini更改允許上...

使用vi或vim開啟php.ini #vim /etc/php/apache/php.ini 找到以...

PHP 字串字數計算並隱藏

PHP 字串字數計算並隱藏

fontphoto55 使用PHP substr函式可以做字串切割,但在遇到中文字時記得使用mbsu...

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