不緩存頁(yè)面對(duì)于數(shù)據(jù)實(shí)時(shí)性要求很強(qiáng)的功能來(lái)說(shuō)很重要,以下是 HTML、ASP、PHP 強(qiáng)制不緩存頁(yè)面的代碼。
HTML 強(qiáng)制頁(yè)面不緩存代碼
-
- <meta http-equiv="Pragma" content="no-cache">
- <meta http-equiv="no-cache">
- <meta http-equiv="Expires" content="-1">
- <meta http-equiv="Cache-Control" content="no-cache">
ASP 強(qiáng)制頁(yè)面不緩存代碼
- Response.Buffer = True
- Response.Expires = 0
- Response.ExpiresAbsolute = Now() - 1
- Response.CacheControl = "no-cache"
- Response.AddHeader "Expires",Date()
- Response.AddHeader "Pragma","no-cache"
- Response.AddHeader "Cache-Control","private, no-cache, must-revalidate"
PHP 強(qiáng)制頁(yè)面不緩存代碼
以下代碼即可強(qiáng)制瀏覽器不緩存頁(yè)面內(nèi)容,適用于 HTTP/1.0 及 HTTP/1.1
- header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
- header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
- header('Cache-Control: no-store, no-cache, must-revalidate');
- header('Cache-Control: post-check=0, pre-check=0', false );
- header('Pragma: no-cache');
該文章在 2011/5/6 22:33:48 編輯過(guò)