Re: [SMARTY] optimization techniques
| From: | Erik Torres Serrano | Date: | Fri, 20 Dec 2002 13:26:47 +0000 |
| Subject: | Re: [SMARTY] optimization techniques | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6907@lists.php.net to get a copy of this message | ||
Personally, I prefer to use an extended class of Smarty with a constructor and I declare in the PHP scripts a variable that is an Smarty handle.
$smarty = new Smarty_Temas($TEMAS_status);
As you can see, I pass one parameter to the constructor: $TEMAS_status. Depending of the value of the parameter, the constructor prepare some Smarty variables as cache_lifetime, caching, force_compile and debugging. Then if you wrote the constructor in a smart way, you can have at least, four states: production (not check), development (force recompile), debugging (smarty debug enabled) and caching disabled (not caching).
Using this method I set up Smarty templates for each kind of information, for example, not caching for search results, production state for pages that doesn't change too quick, and so on.
Erik
Rasmus Schultz wrote:
as long as you use caching, I don't really think you have anything to worry about? it a page is cached, it makes no significant difference if it takes 0.1 or 1.0 seconds to compile and render ... and switching off $compile_check doesn't make that much of a difference, so if you find it useful, just keep it on ... ... for example, our site was performing 20 SQL queries per second - thanks to caching, it's down to 1 SQL query per second - and the number of queries doesn't increase with the number of page loads per second, since everything is cached! :) previously, I would never have used stuff like dynamic image width and height lookup, but again thanks to caching, there's no need to worry about such stuff - the only time you really need to worry, is when your template is totally dynamic, i.e. never cached for some reason ... then all the normal programming optimization techniques of course apply: keep the number of loops and if's to as little as possible etc. other than that, I wouldn't worry myself :) --- At 2002-12-19, 23:50:00, Paul Lockaby <paul@dostuff.net> wrote:What optimization techniques can people recommend in a nutshell? Yes, I have read the manual and seen things like turning off $compile_check and use caching, but I'm sure that there are other techniques that may not necessarily be related to settings in Smarty, but rather to the actual programming techniques involved with the templates. Any comments would be appreciated! ~Paul -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php