我使用本教程http://papermashup.com/caching-dynamic-php-pages-easily/来缓存页面
<?php {
$cachefile = $_SERVER['DOCUMENT_ROOT'].'cache.html';
$cachetime = 4 * 60;
// Serve from the cache if it is younger than $cachetime
if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
include($cachefile);
} else {
ob_start(); // Start the output buffer
?>
/* Heres where you put your page content */
<?php
// 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
}
?>
但我收到以下错误
Warning: fopen() [function.fopen]: Filename cannot be empty in
Warning: fwrite(): supplied argument is not a valid stream resource in
Warning: fclose(): supplied argument is not a valid stream resource in
文件的路径是正确的。如果我编辑我自己的文件,但我再次收到错误