服务器反应速度快
<?php
//增加一个过期时间
$cacheTime=10;
//判断:文件不存或者过期了
if(!file_exists("a.html") || time()-filemtime("a.html") > $cacheTime){
//1.开启
ob_start();
echo "<html><a href='#'>aa</a></html>";
//2.输出缓冲区的内容
$file = ob_get_contents();
//echo $file;
//die;
//3.写入
$f_file = fopen("a.html","w") or die("Unable to open file!");
fwrite($f_file,$file);
fclose($f_file);
}else{
echo file_get_contents("a.html");
die("huancun");
}
?>