function serveCacheIfNecessary() { nitroEnableSession(); if (passesPageCacheValidation() == false) { return false; } $nitrocache_time = getPageCacheTime(); $cachefile = NITRO_PAGECACHE_FOLDER . generateNameOfCacheFile(); if (file_exists($cachefile) && time() - $nitrocache_time < filemtime($cachefile)) { $cache_filemtime = filemtime($cachefile); $quick_refresh_file = getQuickCacheRefreshFilename(); if (file_exists($quick_refresh_file)) { if (filemtime($quick_refresh_file) > $cache_filemtime) { return false; } } $before = microtime(true); usleep(1); header('Content-type: text/html; charset=utf-8'); serveBrowserCacheHeadersIfNecessary($cache_filemtime); serveSpecialHeadersIfNecessary($cache_filemtime); if (loadGzipHeadersIfNecessary()) { $cachefile = $cachefile . '.gz'; } readfile($cachefile); $after = microtime(true); nitroEnableSession(); $_SESSION['NitroRenderTime'] = $after - $before; $_SESSION['NitroNameOfCacheFile'] = generateNameOfCacheFile(); exit; } }
private function quickClearPageCache() { $filename = getQuickCacheRefreshFilename(); return touch($filename); }