Example #1
0
function jpcache_start()
{
    // Initialize cache
    jpcache_init();
    // Skip Caching Feeds
    if (preg_match('#(\\?|\\/)(rss|atom)(\\=|\\/)#', $_SERVER['REQUEST_URI'])) {
        if ($GLOBALS['JPCACHE_SKIP_FEEDS']) {
            jpcache_debug("Not Caching Feeds.");
            return;
        }
        if (is_callable('apache_request_headers')) {
            $headers = apache_request_headers();
            if (isset($headers["A-IM"])) {
                // Textpattern may respond with
                jpcache_debug("Not Caching Feeds, partial Content.");
                return;
            }
        }
        // Phew, Skip is set to false, and no partial content. We can cache this feed.
    }
    // Handle type-specific additional code if required
    jpcache_do_start();
    // Check cache
    if (jpcache_check()) {
        // Cache is valid and restored: flush it!
        print jpcache_flush($GLOBALS["jpcachedata_gzdata"], $GLOBALS["jpcachedata_datasize"], $GLOBALS["jpcachedata_datacrc"]);
        // Handle type-specific additional code if required
        jpcache_do_end();
        exit;
    } else {
        // if we came here, cache is invalid: go generate page
        // and wait for jpCacheEnd() which will be called automagically
        // Check garbagecollection
        jpcache_gc();
        // Go generate page and wait for callback
        ob_start("jpcache_end");
        ob_implicit_flush(0);
    }
}
function jpcache_start()
{
    // Initialize cache
    jpcache_init();
    // Handle type-specific additional code if required
    jpcache_do_start();
    // Check cache
    if (jpcache_check()) {
        // Cache is valid and restored: flush it!
        print jpcache_flush($GLOBALS["jpcachedata_gzdata"], $GLOBALS["jpcachedata_datasize"], $GLOBALS["jpcachedata_datacrc"]);
        // Handle type-specific additional code if required
        jpcache_do_end();
        exit;
    } else {
        // if we came here, cache is invalid: go generate page
        // and wait for jpCacheEnd() which will be called automagically
        // Check garbagecollection
        jpcache_gc();
        // Go generate page and wait for callback
        ob_start("jpcache_end");
        ob_implicit_flush(0);
    }
}