function writeLoadTime($time) { if (passesPageCacheValidation() == false) { return false; } file_put_contents(NITRO_PAGECACHE_FOLDER . 'meta.html', generateNameOfCacheFile() . ' : ' . $time . ' ; ', FILE_APPEND | LOCK_EX); }
function serveSpecialHeadersIfNecessary($filemtime) { $headers_file = NITRO_HEADERS_FOLDER . generateNameOfCacheFile(); if (file_exists($headers_file) && filemtime($headers_file) >= $filemtime) { $headers = explode("\n", file_get_contents($headers_file)); foreach ($headers as $header) { header($header, true); } } }
function serveCacheIfNecessary() { if (!isset($_SESSION)) { session_start(); } if (passesPageCacheValidation() == false) { return false; } $cachefile = NITRO_PAGECACHE_FOLDER . generateNameOfCacheFile(); if (file_exists($cachefile) && time() - NITROCACHE_TIME < filemtime($cachefile)) { $before = microtime(true); header('Content-type: text/html; charset=utf-8'); serveBrowserCacheHeadersIfNecessary(); if (loadGzipHeadersIfNecessary() == true) { readfile($cachefile . '.gz'); } else { readfile($cachefile); } $after = microtime(true); if (decideToShowFrontWidget()) { $renderTime = $after - $before; $nameOfCacheFile = generateNameOfCacheFile(); $originalRenderTime = (double) getLoadTime(); $faster = (int) ($originalRenderTime / $renderTime); include NITRO_FOLDER . 'core/frontwidget.php'; } exit; } }