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

PHP無法保存SESSION的問題

PHP無法保存SESSION...

一天,客戶反應系統後台無法登入。 而這問題是發生在客戶電腦更換了IP位置。 而我這邊也只是開放新的I...

PHP如何移除 x-powered-by 資訊

PHP如何移除 x-powe...

xpoweredby 主動披露使用程式版本訊息,增加資安風險。 可透過以下方式隱藏 xpowered...

使用PHP取得指定月份最後一天的日期

使用PHP取得指定月份最後一...

使用PHP要如何抓某個月份的最後一天 例如抓本月份的話可以使用下列範例: date(&#;Ymt&#...

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