As Web applications become more and more complex, cleverdevelopers can use application-level caching to improve the performanceof their PHP scripts. This article shows you how, discussing the PEARCache_Lite class with examples that illustrate how it can be used in alive environment.
And that's about all we have time for. In this article, I introduced you to the PEAR Cache_Lite class, a PHP class designed specifically to provide a robust caching mechanism for Web pages. I showed you how to configure the location and the lifetime of the cache, and demonstrated how to use the class to cache both static HTML content and dynamic PHP output. I also gave you a quick tour of the Cache_Lite class' two variants, the Cache_Lite_Output and Cache_Lite_Function classes, illustrating how they could be used to cache blocks of output and function return values, respectively. Finally, I wrapped things up with a real-world example, showing you how a cache can make a substantial difference when dealing with complex, XML-based applications like Amazon Web Services.
In case you'd like to learn more about the topics discussed in this article, you should consider visiting the following links:
Documentation for the PEAR Cache_Lite class, at http://pear.php.net/package-info.php?pacid=99
phpCache, a lightweight alternative to Cache_Lite, at http://0x00.org/php/phpCache/, and a tutorial on how to use it, at http://www.sitepoint.com/article/685
A comprehensive resource on the topic of Web caching, at http://www.web-caching.com/
An article discussing the benefits of caching your Web content, at http://www.ariadne.ac.uk/issue4/caching/
Using Amazon Web Services With PHP And SOAP, at http://www.melonfire.com/community/columns/trog/article.php?id=162
Until next time...stay healthy!
Note: Examples are illustrative only, and are not meant for a production environment. Melonfire provides no warranties or support for the source code described in this article. YMMV!