13 replies on “PHP Caching”

  1. From my own experiences, putting stuff on the filesystem is plenty fast for most operations – the operating system caches filesystem calls so if a cached file is used a lot then it’ll be in memory, and probably managed more intelligently than what a PHP script can do in with limited access to resource accounting.
    Still, worth a shot!

  2. For my bittorrent tracker I use turck-mmcache to cache the compiled php code, it works fantastically and compiles in as a module easily, because the tracker would load and compile thousands of times a minute the system load average was hitting 10 with only 3000 users, now with over 20,000 users on the same machine the load average idles around .6 and sometimes touches 1.

    For caching the output I use memcached, finding a php api for it was hell at the time none of the available scripts worked, once I got it running it made a big change in the way I code pages and handle output, the statisize plugin you worked on would be an ideal candidate to adapt for memcached.

  3. Turck MMCache is pretty good. I use it with several WAMP installations. Unfortunately the original developer left the project for a job at Zend. Thus the code has not been updated for a year or so.
    – If anyone needs Win32 build for the latest PHP versions, make a visit to localfoo.info.

  4. Now THIS is a topic (caching) that is close to my heart, and I’ve done a lot of research. I’ll give you a brief rundown of what I’ve found. Take from it what you will…

    Filesystem: I’ve found that this is the best “all round” solution. While it’s true that accessing the FS is pretty slow, the speed at which PHP can read/write is nothing to be sneezed at. Not to mention the support is out of the box and it’s hardly a complex task to write a caching handler. Added to that, garbage collection (gc) is fairly easy to handle.

    Shm (& SystemV): I’ve found PHP’s handling of Shm to be… well, questionable at best. There are all kinds of limitations on it and I found myself getting some odd, unexplained issues and errors cropping up. Not recommended.

    DB: This was something I took a very close look at, MySQL’s implementation of MEMORY tables. Basically they exist in the same way as regular table structures (with some limitations), however table data is stored in the memory. This would’ve been perfect for some of the projects I did all this research for, but for the fact that the the rows are of fixed length (goodbye TEXT and BLOB types). This was not a limitation I was willing to work around, so it went out the window however I’m sure I read somewhere that variable lengths will be implemented somewhere down the line. Err, I’m not sure how useful this would be for page caching, I was more thinking along the lines of arbitrary data.

    Turck-MMCache: Beautiful program… if you’re still running PHP 4.2.x. As somebody pointed out earlier, the original developer is gone and releases are few and far between. CVS version is buggy as hell and forget PHP5 support. Also found it crashed Apache2.

    memcached: Jeremy pointed this out above, and I cannot sing its praises enough. I don’t know what he meant when he said he couldn’t find a PHP API for it, as there’s been a stable extension in PECL for a few months now. Unfortunately, it doesn’t support multiple memcached servers, which is one of its coolest features. But hey, not everyone is sitting on multiple boxes, and I’m sure you could write a PHP script wrapper to implement it. It’s delightfully simple and I’ve found it works very well. That said, you have to do a fair bit of work to get it off the ground and it’s *nix only, unless you want to install Cygwin. GC is handled by memcached too, so there goes that consideration. Highly recommended.

    The only other solution I can think of is the ZPS, however I’ve never had a chance to play with that, so I don’t know. Hope all this helps in some little way.

  5. check out jpcache http://www.jpcache.com/

    This is a very different approach to caching. But for DB driven websites with mostly static content it can speed up the processing upto 4-6 times and consume much less resources

    I am a contributing editor for Mortgage Fit The technology team did some research and once they implemented Jpcache the page processing time went down from 2.6ms to like .4 ms

  6. Is anyone besides me having trouble with installing the memcached extension with php 5.2.0? It keeps telling me the APIs don’t match. PECL doesn’t have memcached 2.1 in it… so not sure how to proceed. Any suggestions welcome.

Comments are closed.