Re: [SMARTY-GENERAL] A few quick questions on caching

From: Date: Sun, 07 Apr 2002 23:08:05 +0000
Subject: Re: [SMARTY-GENERAL] A few quick questions on caching
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3551@lists.php.net to get a copy of this message
Michal Prinke wrote:
Hi! I think I do not fully understand the Smarty cache... 1. the thing that is being cached is the final, generated document, right?
Correct, it caches what comes back from your display() or fetch() function call.
2. so does it make sense to use caching on site which strongly depends on a database, with the values changing from second to second?
Correct, page caching is good for pages that generate identical content during the time it takes the cache to expire.
3. will Smarty regenerate the page when I change a single variable passed to its template?
If you have compile_check turned on, then the caches will regenerate when a template or config file changes that is part of that cache. Normally you would only have compile_check on during development, since testing all the templates/configs on each page hit is a slight decrease in performance.
4. is there any possibility of serving an obsolete version of a page?
obsolete in what sense? If a cache expires, it is overwritten with a new cache. If you want to keep older versions of the cache, that is beyond the scope of Smarty's caching purpose. I suppose you could periodically fetch the pages and keep them around at the application level.
5. are there any drawbacks of caching?
If your pages change every click, then that would be a drawback. Use caching where expensive operations (such as db calls) can be minimized. For instance, if you have a front page of a newspaper that does a bunch of db calls to generate the content, and these db calls are generally redundant, then cache the page. This will help tremendously. If there is a particular part of the page that cannot be cached (such as banners or polls), then use the {insert} tag to imbed dynamic content in the cached page.
PS. Where to get the CVS version of Smarty?
http://smarty.php.net/

« previous php.smarty.general (#3551) next »