我想缓存一些在每小时开始时(xx:00:01)显示不同数据的php页面?
到目前为止,我已经找到了一种在访问(或修改文件)时缓存页面 +1 小时的方法,但是如果用户在 xx:59:00 访问该页面,那么在 xx+1:00:01 ,他将看到缓存的页面数据,而不是新显示的数据。
我需要写什么来获得一个常规的“最小时”缓存到期,最好使用.htaccess?
最终代码(非 htaccess):
$nexthour = mktime(date("H")+1, 00, 20) - mktime();
header("Cache-Control: public, must-revalidate, max-age=".$nexthour.", s-maxage=".$nexthour);
在每一页的顶部。