Using cache - is this correct?
| From: | Michal Prinke | Date: | Sat, 11 May 2002 01:16:17 +0000 |
| Subject: | Using cache - is this correct? | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-4163@lists.php.net to get a copy of this message | ||
Is this the correct way of using Smarty's cache???
1. All the templates stay exactly the same as without caching;
2. Inside my PHP script I write:
> $sm->caching = true;
> $sm->caching = -1; // never
> if (!$sm->is_cached("index.tpl")) {
> // connect to db
> // fetch rows
> // assign variable by $sm->assign()
> }
> $sm->display("index.tpl");
3. Inside my PHP script that changes the database content:
> $sm->caching = true;
> // connect to db
> // insert/update rows
> $sm->clear_cache("index.tpl");
...?
Going further. The PHP processing is now dramatically cut when the database
content do not change. Then, it can be nice to re-cache only some parts of the
template... e.g. only the "poll" part of "index.tpl" when user adds a new
poll...
But that is a completely different story ;)))