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

使用javascript獲取ckeditor textarea的textarea值

使用javascript獲取...

一般來說,若我想使用 javascript 來得到 textarea 的值。 可以使用以下方式: 首...

點選檔案下載卻直接執行開啟

點選檔案下載卻直接執行開啟

遇到一個情況。 使用者開啟瀏覽器點選某個連結檔案時,不會執行下載而是直接開啟檔案。 原本如果只是圖片...

.htaccess設定網站預設首頁次序

.htaccess設定網站預...

一般php空間預設設定是index.php為首頁。 所以如果網站用index.php做首頁,就不需要...

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