PHP 简单的页面缓存

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 简单的页面缓存相关的知识,希望对你有一定的参考价值。

$cacheFile = 'cache/index-cached.html';
$cacheTime = 4 * 60;
// Serve the cached file if it is older than $cacheTime
if (file_exists($cacheFile) && time() - $cacheTime < filemtime($cacheFile)) {
    include($cacheFile);
    exit;
}
// Start the output buffer
ob_start();

/* Heres where you put your page content */

// Cache the contents to a file
$cached = fopen($cacheFile, 'w');
fwrite($cached, ob_get_contents());
fclose($cached);
ob_end_flush(); // Send the output to the browser

以上是关于PHP 简单的页面缓存的主要内容,如果未能解决你的问题,请参考以下文章

简单的PHP页面缓存技术

PHP 简单的页面缓存

PHP 带缓存的简单下载页面

PHP 简单的页面缓存

php静态缓存简单制作

php最基本的缓存之一页面缓存