静的なHTMLでPHPスクリプトの出力をキャッシュしたいと思います。いくつかのガイドとコード例を試しましたが、成功しませんでした。ここでPHPを静的なHTMLでキャッシュする
私のコードです:
<?php
$cachefile = 'cached_php.html';
$cachetime = 18000;
if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
include($cachefile);
exit;
}
ob_start();
?>
<html>
<script src="/feeds/phpscript.php"></script>
</html>
<?php
$fp = fopen($cachefile, 'w');
fwrite($fp, ob_get_contents());
fclose($fp);
ob_end_flush();
?>
しかし、私が得るすべてのコンテンツとcached_php.htmlです:あなたが実行する
<html>
<script src="/feeds/phpscript.php"></script>
</html>
何を得ることが期待されましたか? – Yoshi