From aea612a9fbd4595e9a4787ac7b62c8633aa60a17 Mon Sep 17 00:00:00 2001 From: Yaya Laressa Date: Tue, 6 Jul 2021 08:26:33 +0700 Subject: [PATCH] Fix cache minify --- system/includes/dispatch.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/system/includes/dispatch.php b/system/includes/dispatch.php index 78a8158..4902e32 100644 --- a/system/includes/dispatch.php +++ b/system/includes/dispatch.php @@ -480,6 +480,7 @@ function render($view, $locals = null, $layout = null) if (config('generation.time') == 'true') { ob_start(); require $layout; + static $total_time; // Fix minify $time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]; $total_time = round($time, 4); echo "\n" . ''; @@ -489,15 +490,21 @@ function render($view, $locals = null, $layout = null) } if (!$login && $view != '404') { if (!file_exists($cachefile)) { + if (config('cache.timestamp') == 'true') { + echo "\n" . ''; + } if(config('cache.minify') == 'true') { - $content = minify_html(ob_get_contents()); // Minify HTML + $content = minify_html(ob_get_contents()); + if (config('generation.time') == 'true') { + $content .= "\n" . ''; + } + if (config('cache.timestamp') == 'true') { + $content .= "\n" . ''; + } + file_put_contents($cachefile, $content); } else { - $content = ob_get_contents(); // Un-Minify HTML - } - if (config('cache.timestamp') == 'true') { - $content .= "\n" . ''; + file_put_contents($cachefile, ob_get_contents()); } - file_put_contents($cachefile, $content); } } echo trim(ob_get_clean());