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.name

直接在PHP重新命名帶有前綴...

直接在php檔案裡加入以下指令 sessionname(&#;SecurePHPSESSID&#;)...

使用.htaccess關閉特定文件的緩存

使用.htaccess關閉特...

以特定檔案為例 <Files page.php> FileETag None Header unse...

如何緩存靜態資源使用HTTP緩存

如何緩存靜態資源使用HTTP...

配置服務器以返回CacheControlHTTP響應標頭: CacheControl: maxage...

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