Re: [SMARTY] Caching parts of a page
| From: | Monte Ohrt | Date: | Mon, 22 Apr 2002 20:20:18 +0000 |
| Subject: | Re: [SMARTY] Caching parts of a page | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-3842@lists.php.net to get a copy of this message | ||
It would be nice to automatically have certain functions cached or not. To really do it right would take bit of work, it isn't trivial to do. It would probably take some major changes to the parsing engine. This will probably happen eventually, but not anytime soon.
A work around (something I've pondered but never got around to coding) is a caching wrapper function.
For those of you browsing the mailing list archive, the following is a possible EXAMPLE i.e. it does not exist (unless someone codes it and contributes it ;-)
Example of possible wrapper function:
{insert name="wrapper" function="html_options" cache_lifetime="86400" values=$values output=$output}
Here we have just made the html_options function cached for a day. wrapper requires "function" and "cache_lifetime" attributes. The rest of them are passed to the function being cached. I'm sure there are some "gotchas" I haven't thought of, but something like this might be doable, at least for plugin functions... and this still isn't automatic. For your designers to use a poll, they must still use the insert function.
Monte
Ivo Jansch wrote:
Hi, MishY wrote: So is there a way of seperating cached, and not-to-be cached items from the template ? Currently, there's no other way than the insert handler. But I would like to propose another way, and I wonder what Andrei and Monte think of this: I want to supply a set of functions for use in templates to our template design staff. I would like it if they would never have to worry wether or not a function is dynamic or can be cached. So they would just do {poll} in a template, or {slashdot_headlines}, and the poll would never be cached, and the slashdot headlines may be cached for a certain amount of time. Therefor, it would be nice if we could specify for each function/plugin/tag, if it is cachable or not. Would this be feasible? Greetings, Ivo-- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc.