增加缓存

pull/1/head
xiaoz 7 years ago
parent 5c3e817e12
commit af3e433b00

@ -17,6 +17,14 @@
//对URL进行md5加密用于文件存储 //对URL进行md5加密用于文件存储
$filename = md5($url); $filename = md5($url);
$filename = "caches/".$filename.".md"; $filename = "caches/".$filename.".md";
//获取文件修改时间
@$ftime = filemtime($filename);
(int)@$ftime = date('YmdH',$ftime);
(int)$thetime = date('YmdH',time());
//计算时差
$diff = $thetime - $ftime;
//获取样式 //获取样式
$style = $_GET['style']; $style = $_GET['style'];
//获取方法 //获取方法
@ -33,7 +41,7 @@
} }
//如果文件存在 //如果文件存在
if(is_file($filename)) { if((is_file($filename)) && ($diff <= 1)) {
$text = file_get_contents($filename); $text = file_get_contents($filename);
} }
//文件不存在 //文件不存在

@ -40,5 +40,6 @@
} }
}); });
</script> </script>
<!--页面缓存于<?php echo $ftime; ?>-->
</body> </body>
</html> </html>
Loading…
Cancel
Save