RE: [SMARTY-DEV] Is Smarty using PHP output buffering?

From: Date: Tue, 06 May 2003 19:19:34 +0000
Subject: RE: [SMARTY-DEV] Is Smarty using PHP output buffering?
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-1376@lists.php.net to get a copy of this message
I have to agree that anything that speeds things up is a good idea :) On-the-other-hand, I'm nervous about a change on this scale based on a single slide in a presentation. It seems that the point of output buffering is to delay stream results until everything has been collected into a hidden internal variable within the PHP engine. That's where the memory issue comes from: results that are normally flushed to the stream are temporarily cached internally. Not a bad trade-off, in general. I come from the school of thought that you don't do intermediate echos/prints to the stream in your code--instead you build an internal string, just like OB does, except that unlike with OB, you have full control of the process during the entire execution chain. At the end, you put results to the stream (or you do intermediate flushes as appropriate). Of course, this means that the client sees nothing until the entire stream is built--the same as if OB is on, and I figure that this is one of the main reasons that display() DOES NOT use OB by default. Having OB on (our not flushing intermediate results) means that the CLIENT may be 'blocked' until ALL results are available. In most situations, this is not the desired result. To recap, using echo/prints is a bit easier to implement--you don't have to think about managing your output and if you want to have more efficient buffering (less context flipping between PHP/Apache), you flip the OB switch on. On the other-hand, with a bit more effort/convention, echo/print can be avoided entirely (until the final output stage) for superior control over the final result. In other words, I see OB as a kind of hack for those times where internal representations of output are not being built. From Monte's comments, one can easily get automated OB if they want it by simply overriding the default display in a custom class which re-implements it as an echo $this->fetch($tpl, $cacheid, $compileid);. That should probably be good enough in the interim ;) Theory is awesome, though it would be interesting to hear about actual benchmarks and techniques that people use to send JUST ENOUGH info to the client so that they don't 'feel' blocked. __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com

« previous php.smarty.dev (#1376) next »