Paul M Foster wrote:
This question may be too complex for a reasonable answer on this list, but I'll ask anyway. If a page has static content (no PHP variables, etc.), I can understand how caching works. The engine just checks to see if it's got a copy of the requested page in the cache, and displays it if so, or fetches it if not. But if a page is populated with variables from a database (for example) which could change from time to time, how could a caching engine possibly cache it? How would it determine whether to re-fetch the page or use the cached version?
By setting a duration during which stale information is not a problem. let's say you have a request for your homepage once per second. Now let's say you display the 10 most recent news articles on your homepage. Now let's say you cache the homepage news articles for 10 minutes. You save a bunch of database queries for every homepage request during those 10 minutes... approximately 600 requests. What does this cost you? You're homepage news articles may be stale for 9 minutes and 59 seconds. This is just a minor example, look at MediaWiki as an example of some heavy computation to render a page. This intense operation is cached so that it not be necessary on every article view. Wikis usually have a high number of read operations versus writes, in fact any site with a high number of reads versus writes probably has an opportunity for caching.
Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php