Have you explored Symfony's caching features yet? You can cache entire
pages, or cache the action without caching the layout (which makes it
easy to keep the logged-in-user aspects of the page dynamic), or even
cache individual components or partials. I've found the performance
benefits of these features to be so dramatic that optimizing the
daylights out of the low-level details of the code doesn't make much
sense, at least not when the optimized version is much less
maintainable and understandable than the original.

Even a highly dynamic site can often take advantage of the cache by
setting the cache lifetime to something quite short, like five
minutes, for the generation of an otherwise expensive thing like a
richly detailed month-long calendar view (I do something like this at
salsadelphia.com).

That doesn't address the extra whitespace in transmission issue of
course. My first thought was "there should be a low-level Apache
module that does that for you." But it turns out that development of
such a module was rejected because mod_gzip saves much more space.
Browser support for mod_gzip appears to be pretty well universal at
this point.

The cost of opening and closing <?php ?> blocks would certainly cease
to be an issue if a bytecode cache were standard equipment in PHP.
That's way overdue honestly.

On Mon, Jan 26, 2009 at 9:30 AM, colnector (colnect.com)
<[email protected]> wrote:
>
> The questions also appear on:
> http://www.symfony-project.org/forum/index.php/m/70751/#msg_70751
> and
> http://www.symfony-project.org/forum/index.php/t/18496/
>
> Symfony templates are simple HTML embedded with PHP in them.
> For this reason they present the following downsides:
> * An extra amount of unneeded whitespace exists. Since you'd prefer to
> have a readable file, you organize it nicely. However, the generates
> files are needlessly bigger.
> * There's a price for PHP going in and out of scripting mode by using
> <?php and later ?>.
> * There's a price for calling PHP's echo again and again instead of
> once.
>
> Though these prices may be negligible for some sites, I feel they are
> becoming more and more costly for dynamic sites. Also, the template is
> not that readable with <?php and ?> cluttering it everywhere.
>
> Your opinions / insights are welcomed.
>
> Here's a sample of two alternative:
>
> Symfony style:
>
> <ul>
>  <li><?php echo link_to('1', 'module/action');?></li>
>  <li><?php echo link_to('2', 'module/action');?></li>
>  <li><?php echo link_to('3', 'module/action');?></li>
>  <li><?php echo link_to('4', 'module/action');?></li>
>  <li><?php echo link_to('5', 'module/action');?></li>
>  <li><?php echo link_to('6', 'module/action');?></li>
> </ul>
>
>
>
> A more optimized PHP script could be:
>
> <?php echo '<ul><li>'
>    .link_to('1', 'module/action')
>    .'</li><li>'
>    .link_to('2', 'module/action')
>    .'</li><li>'
>    .link_to('3', 'module/action')
>    .'</li><li>'
>    .link_to('4', 'module/action')
>    .'</li><li>'
>    .link_to('5', 'module/action')
>    .'</li><li>'
>    .link_to('6', 'module/action')
>    .'</li></ul>'
>    ;
>
>
>
> The second script, although looks less like HTML, produces a
> whitespace-free output, uses a single echo command and doesn't force
> PHP's parser to go back and forth. Of course in this small example the
> differences are meaningless but I hope you understand my point.
>
> Your opinions / insights are welcomed.
> >
>



-- 
Tom Boutell

www.punkave.com
www.boutell.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to