batcache::add_debug_from_cache PHP Method

add_debug_from_cache() public method

    function add_debug_from_cache()
    {
        $seconds_ago = time() - $this->cache['time'];
        $generation = $this->cache['timer'];
        $serving = $this->timer_stop(false, 3);
        $expires = $this->cache['max_age'] - time() + $this->cache['time'];
        $html = <<<HTML
<!--
\tgenerated {$seconds_ago} seconds ago
\tgenerated in {$generation} seconds
\tserved from batcache in {$serving} seconds
\texpires in {$expires} seconds
-->

HTML;
        $this->add_debug_html_to_output($html);
    }

Usage Example

Beispiel #1
0
            $cache_time = strtotime($batcache->cache['headers']['Last-Modified'][0]);
        } else {
            $cache_time = $batcache->cache['time'];
        }
        if ($client_time >= $cache_time) {
            $three04 = true;
        }
    }
    // Use the batcache save time for Last-Modified so we can issue "304 Not Modified" but don't clobber a cached Last-Modified header.
    if ($batcache->cache_control && !isset($batcache->cache['headers']['Last-Modified'][0])) {
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $batcache->cache['time']) . ' GMT', true);
        header('Cache-Control: max-age=' . ($batcache->cache['max_age'] - time() + $batcache->cache['time']) . ', must-revalidate', true);
    }
    // Add some debug info just before </head>
    if ($batcache->debug) {
        $batcache->add_debug_from_cache();
    }
    $batcache->do_headers($batcache->headers, $batcache->cache['headers']);
    if ($three04) {
        header("HTTP/1.1 304 Not Modified", true, 304);
        die;
    }
    if (!empty($batcache->cache['status_header'])) {
        header($batcache->cache['status_header'], true);
    }
    // Have you ever heard a death rattle before?
    die($batcache->cache['output']);
}
// Didn't meet the minimum condition?
if (!$batcache->do && !$batcache->genlock) {
    return;