Smarty compiling & caching issues - possible solution
| From: | Monte Ohrt | Date: | Fri, 05 Oct 2001 15:37:56 +0000 |
| Subject: | Smarty compiling & caching issues - possible solution | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-1609@lists.php.net to get a copy of this message | ||
There is an issue that has been coming up repeatedly on the mailing
list, which I will address here.
Currently if you have caching enabled it overrides the compile_check
flag, meaning that if a template's contents changes you don't see them
until the cache expires. If you want to force the change, you must turn
caching off, turn compile_check on, clear the cache directory manually
and reload the page. Several requests have been made to automatically
clear cache files whenever a template is recompiled, and do this when
compile_check is true, regardless of the caching setting.
I've been working on a solution, and it will require a fundamental
change in the way Smarty behaves. Currently, caching overrides the
compile_check flag. This means that after a template compiles once, the
cached version is used until it expires, regardless if a template
changes during that time or not.
At first I thought this would be easy to fix. If caching is true and
compile_check is true, process the template. If it needed a recomiple,
then clear the cache file. But what happens if a template included by
the main template was changed? You won't see the changes because the
cached file is based on the top level template.
So, the sensible solution is to _always_ clear the cache file when
caching is true and compile_check is true. This essentially disables
caching altogether whenever compile_check is enabled. Or another way to
put it, compile_check now overrides caching instead of the other way
around.
The PROS: Anytime you have compile_check enabled, template changes are
always seen, regardless of cache setting.
The CONS: Anyone who currently has caching on and compile_check on will
no longer benefit from caching, the behavior CHANGED.
Thoughts? Anything I missed?
Here is the simple change in Smarty to make this happen:
if($this->compile_check) {
$this->caching = false;
}
Monte
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/