码迷,mamicode.com
首页 > Web开发 > 详细

HTML、ASP、PHP 强制不缓存页面

时间:2015-05-04 15:11:46      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

不缓存页面对于数据实时性要求很强的功能来说很重要,以下是 HTML、ASP、PHP 强制不缓存页面的代码。

HTML 强制页面不缓存代码

<!-- no cache headers -->
<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">
<!-- end no cache headers -->

ASP 强制页面不缓存代码

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 强制页面不缓存代码
以下代码即可强制浏览器不缓存页面内容,适用于 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‘);    

HTML、ASP、PHP 强制不缓存页面

标签:

原文地址:http://www.cnblogs.com/atlanticD/p/4476188.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!