/ / Cache do arquivo php e retornar o arquivo html em cache - php, performance

Cache de arquivos php e retornar o arquivo html em cache - php, performance

Eu tenho uma tabela mysql realmente grande, portanto estou tentando chache todo o arquivo php e retornar o arquivo html em cache.

Eu usei esse aqui Colocando em cache páginas PHP dinâmicas facilmente e funciona muito bem, mas quando chegou a hora de escrever o novo arquivo html, demora muito tempo para carregar ... Onde preciso modificá-lo ...

Código 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

Respostas:

0 para resposta № 1

Supondo que você está falando de tabela HTML, esse cache não irá acelerar o tempo de carregamento.
O navegador leva muito tempo para renderizar uma tabela grande, não o PHP, para gerá-la.

Assim, para tornar as coisas mais rápidas, você precisa reduzir o tamanho da tabela ou implementar algum tipo de paginação ou carregamento dinâmico.