- php的缓存技术,把所有的动态页面缓存在一个文件里进行调用和定期更新缓存,
ob_start()
ob_get_contents()
ob_clean
ob_get_clean
<?php
if(file_exists('./cache/index.html')){
include './cache/index.html';
$now_time = time();
$last_time = filemtime('./cache/index.html');
if(($now_time - $last_time)/60>30){
unlink('./cache/index.html');
}
exit;
}
ob_start();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>php</title>
</head>
<body>
......
</body>
</html>
<?php
$content = ob_get_contents();
$fp = fopen('./cache/index.html','w');
fwrite($fp,$content);
fclose($fp);
ob_flush();
flush();
ob_end_clean();
?>