+
95
-

php如何设置页面过期时间?

php

php如何设置页面过期时间?

网友回复

+
15
-

<?php
header("Date: ".gmdate("D, d M Y H:i:s", time())." GMT");
header("Last-Modified: ".gmdate("D,...

点击查看剩余70%

+
15
-

如果是想在服务器端缓存生成的html页面的话,可以检测页面生成时间,设定过期时间,然后来输出,代码如下:

<?php

if(is_file('./index.html') && (time()-filemtime('./index.html')) < 60){ 
  // 假设缓存时间是60秒
  // 获取页面
  require_once('./index.html');
}else{
  // 重新生成一份静态页面
 ...

点击查看剩余70%

我知道答案,我要回答