cache禁止瀏覽器快取網頁 No Cache

2020-03-07

[PHP] cache禁止瀏覽器快取網頁 No Cache

資料來源:http://dorothycode.blogspot.com/2010/10/php-cache-no-cache.html

[PHP] cache禁止瀏覽器快取網頁 No Cache
避免proxy或bowser cache住你的網頁。(如此的話使用者看到的都會是舊的畫面)

HTML Meta Tag:
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache"> 舊式寫法,加是為了相容性。
<meta http-equiv="expires" content="0"> 將網頁設做立即過期。
In PHP:
<?php
// Expires in the past
header("Expires: Mon, 26 Jul 1990 05:00:00 GMT");
// Always modified
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
?>

Contact

Github

Codepen

歡迎參觀我的賣場
© 2013 Copyright Digishot Web | Design Tools
Visitors【633368】
digishot webdesign studio