PHPBuilder - Boost PHP Site Performance with Zend Framework Data Caching Page 2



RSS Twitter
Articles Site Operation

Boost PHP Site Performance with Zend Framework Data Caching - Page 2

by: W. Jason Gilmore
|
December 1, 2010

Caching Paginated Results

I simplified the previous example somewhat so as not to get lost in myriad unrelated details. However, now that you understand how the general caching process works, let's dive a bit deeper into how I go about caching paginated data. Because each page within the paginated list is of course unique, repeatedly caching the data using the games token isn't acceptable. Instead, I use the page number to create a dynamic token, like this:
$cacheToken = $this->platform->name."_".$this->page;
Therefore, every time the page changes, the cache token will be updated accordingly, creating a new cache file (e.g. xbox_1, xbox_2, xbox_3...). This token is then passed into the load() method just as before:
... if ( ($gamesPaginator = $cache->load($cacheToken)) === false) { ...

Caching Resources

If you're building a website that will receive any significant amount of traffic, then caching is one of the most effective and easiest ways to boost performance and keep your users happy. Be sure to check out the following resources for more information:

About the Author

Jason Gilmore is the founder of the publishing and consulting firm WJGilmore.com. He also is the author of several popular books, including "Easy PHP Websites with the Zend Framework", "Easy PayPal with PHP", and "Beginning PHP and MySQL, Fourth Edition". Follow him on Twitter at @wjgilmore.

« Previous Page
1
|
2

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
W. Jason Gilmore

Comment:



Comment:

(Maximum characters: 1200). You have characters left.