Re: Smarty compiling & caching issues - possible solution

From: Date: Sat, 06 Oct 2001 16:48:16 +0000
Subject: Re: Smarty compiling & caching issues - possible solution
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1618@lists.php.net to get a copy of this message
Bob wrote: > > If I have caching enabled for 1 hour then any content I change will be done > within an hour, right? Currently, if you have caching enabled _and_ check_templates enabled, the changed templates will recompile after the cache expires. If check_templates is not enabled, the changed templates will never get updated after the initial compile. Templates are _always_ compiled initially, regardless of caching and check_templates settings. This is useful so you can wipe the entire templates_c directory without worrying about settings. What we are thinking of doing is tracking what templates are involved with a cached page (maybe a wddx line at the top of the cache file, or another file along side of the cache file?). Then if caching and check_templates is enabled, these templates are tested on each invocation and if any one of the templates has been updated, the cache clears and the templates recompile. On high traffic sites where performance is the utmost concern, you would want to turn off check_templates. Another completely different idea is a helper application that runs periodically doing tests of caches and template files, and clears them when necessary. This would definately help in the performance area since it does not impact the runtime operations of Smarty. It does add a slight level of complexity for the site maintainer. > Plus, I'm assuming you have caching turned on > because you have a high traffic site so it would seem like that is the trade > off you have to decide. > > If you want speed by caching then you have to delay the time your site is > updated. > If you want real time updates then you have to put more load on your > database. > > Am I off here or what? > > Monte Ohrt wrote: > > > 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/ > > > > --- > > You are currently subscribed to smarty as: whyisityou2@yahoo.com > > To unsubscribe send a blank email to $subst('Email.Unsub') > > Visit Smarty's homepage at > > http://www.phpinsider.com/php/code/Smarty/ > > _________________________________________________________ > Do You Yahoo!? > Get your free @yahoo.com address at http://mail.yahoo.com

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