当前位置: 我爱LAMP > PHP > 文章正文

用php控制页面的过期时间

发表于 2009-12-05 00:18    文章来源:互联网

用php控制页面的过期时间:
控制页面的过期主要是对If-Modified-Since控制.
下面的程序实现页面5分钟后过期
<?php
$headers = apache_request_headers();
$client_time = (isset($headers['If-Modified-Since']) ? strtotime($headers['If-Modified-Since']) : 0);
$now=gmmktime();
$now_list=gmmktime()-60*5;
if ($client_time<$now and $client_time >$now_list){
header(‘Last-Modified: ‘.gmdate(‘D, d M Y H:i:s’, $client_time).’ GMT’, true, 304);
exit(0);
}else{
header(‘Last-Modified: ‘.gmdate(‘D, d M Y H:i:s’, $now).’ GMT’, true, 200);
}
?>

本文链接: http://www.52lamp.com.cn/detail/5769.html

喜欢我爱LAMP – lamp开发程序交流学习平台的文章,那就通过 RSS Feed 功能订阅阅读吧!