Re: using APC as content-cache?

From: Date: Fri, 29 Apr 2005 00:51:31 +0000
Subject: Re: using APC as content-cache?
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-2316@lists.php.net to get a copy of this message
Andreas Korthaus wrote:
Hello! With Turck mmCache/eAccelerator you can do something like that: eaccelerator_cache_page( $_SERVER['PHP_SELF'].'?GET='.serialize($_GET), 1800); This will cache the whole output of this php-script for 1800 seconds. Caching the whole output seems to be very useful: Requests to index.php of phpmyadmin: (requests/second) php without any cache: 8.91 php with opcode-cache: 43.27 php with content-cache: 543.48 from: http://turck-mmcache.sourceforge.net/index_old.html#bench I have had a look at php_apc.c where I could find some PHP-functions of APC, but nothing like apc_cache_page() or something like that. Is there any possibility to cache a whole page? Of course you could use ob-functions with apc_fetch/apc_store, but this would be implemented in php and by far not as fast as eAccelerator.
Interesting idea. Although it seems like it could be done almost completely in user-space, couldn't it? Perhaps something like this wrapper set as your auto_prepend? $page_id = md5($_SERVER['REQUEST_URI']); if(!$content = apc_fetch($page_id)) {
    ob_start();
    require $_SERVER['SCRIPT_FILENAME'];
    $content = ob_end_clean();
    apc_store($page_id, $content, 1800);
} echo $content; exit; Would be interesting to see the performance numbers on this approach. Then again, for full content-caching like this, a 404 handler which saves a static version of the content plus a cron job that periodically removes files older than 30 minutes might be even more effective. I would think that something like the above would be most effective when used in a partial page caching context. -Rasmus

« previous php.pecl.dev (#2316) next »