ページをキャッシュするために、このチュートリアルhttp://papermashup.com/caching-dynamic-php-pages-easyly/を使用しています
<?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
ファイルへのパスは正しいです。ファイルを編集すると、自分自身が含まれますが、再びエラーが発生します