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 Caching Headers

PHP Caching He...

pexelsphotospeed 最近測試平台系統執行速度,老實說測試的有點無力~ 總覺得能做的可以...

在PHP強制顯示錯誤訊息的方法

在PHP強制顯示錯誤訊息的方...

若是單一檔案,只需要在每個PHP檔案裡添加下列行: iniset(&#;displayerrors&...

分享 斜槓青年正夯,什麼都會才是王道?他舉賈伯斯、巴菲特為例,勸你萬萬不可跨領域-風傳媒

分享 斜槓青年正夯,什麼都會...

巴菲特:「了解自己的能力圈,待在裡面。這個圈圈到底有多大其實無關緊要。知道圈圈的邊線究竟在哪則非常重...

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