首页 > Web开发 > 详细

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

时间:2015-05-04 15:11:29      阅读:247      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!