Loading...

使用 .htaccess 關閉緩存

Temperature: 0 °C

Mark ChangMark Chang
author_tools

使用緩存可以提高網站的性能。
可以在.htaccess 文件集標頭中的各種指令指示瀏覽器將文件保留較長時間。
這樣在使用端瀏覽網站時就可以直接使用被緩衝的文件而不用重新查詢資料庫或下載。
這樣網站速度效能會提高許多。

但也許也會有禁用緩衝功能的時候,例如修改網站內容時。
這時我們需要把緩衝功能關閉:

# DISABLE CACHING
<IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires 0
</IfModule>

<FilesMatch "\.(css|flv|gif|htm|html|ico|jpe|jpeg|jpg|js|mp3|mp4|png|pdf|swf|txt)$">
<IfModule mod_expires.c>
ExpiresActive Off
</IfModule>
<IfModule mod_headers.c>
FileETag None
Header unset ETag
Header unset Pragma
Header unset Cache-Control
Header unset Last-Modified
Header set Pragma "no-cache"
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Expires "Thu, 1 Jan 1970 00:00:00 GMT"
</IfModule>
</FilesMatch>

以上紀錄。

參考連結Url link

#故事  #htaccess  #禁用緩衝  #apache  
https://innstory.com/story-使用_htaccess_關閉緩存-2724
apache

Prev
 使用htaccess中更改sessionname

Next
Fatal_error_Allowed_memory_size_of_50331648_bytes_exhausted_tried_to_allocate_12288_bytes_in 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

要如何修改Plesk空間上傳檔案大小的限制

要如何修改Plesk空間上傳...

Plesk的預設狀況下上傳檔案限制為M。 若要修改上傳限制 首先點選開發工具的PHP設定 innim...

PDO PHP - PDOException - Numeric value out of range: 1264 Out of range value for column user_ip at row 1

PDO PHP - PDOE...

最近遇到一個問題,一個Mysql的錯誤訊息。 我想要紀錄一個IP資訊,我會先用以下方式擷取用戶端使用...

使用CSS 讓ul li 橫向水平

使用CSS 讓ul li 橫...

好吧,其實這個css常在用,但我每次都沒特別紀錄,然後每次又忘記然後又要Google。 其實主要就是...

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