-1
我有一個非常大的mysql表,因此我試圖chache整個php文件並返回緩存的html文件。緩存php文件並返回緩存的html文件
我用這一個Caching Dynamic PHP pages easily,它的偉大工程,但是當時間已經到來寫入新的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
是否可以在沒有動態加載的情況下進行。 –
我使用的不是一個html表格。我使用mysql的xampp數據包 –