非常に大きなmysqlテーブルがあるため、phpファイル全体をキャッシュして、キャッシュされたhtmlファイルを返そうとしています。
私はこのキャッシュ動的PHPページを簡単に使用しましたが、うまく機能しますが、新しいhtmlファイルを作成するときが来たら、ロードに非常に時間がかかります...どこを変更する必要がありますか...
PHP コード:
$cachefile = '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);
echo "<!-- Cached copy, generated ".date('H:i', filemtime($cachefile))." -->\n";
exit;
}
ob_start(); // Start the output buffer
/* 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