예제 #1
0
파일: bottom.php 프로젝트: BulatSa/Ctex
function writeLoadTime($time)
{
    if (passesPageCacheValidation() == false) {
        return false;
    }
    file_put_contents(NITRO_PAGECACHE_FOLDER . 'meta.html', generateNameOfCacheFile() . ' : ' . $time . ' ; ', FILE_APPEND | LOCK_EX);
}
예제 #2
0
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);
        }
    }
}
예제 #3
0
파일: top.php 프로젝트: BulatSa/Ctex
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;
    }
}