By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

Why do templates improve performance?

P: n/a
Hello

I'm no PHP expert, and I'm reading "Building scalable web sites". In
the tips section, the author mentions using templates to speed things
up. I was wondering how the template engines manage PHP pages that
contain calls to MySQL: In our application, the data returned is
different for most users, so the resulting page has different
contents. So why do templates (and opcode cache) improve performance?

Thank you.
Aug 25 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi,

Gilles Ganault wrote:
I'm no PHP expert, and I'm reading "Building scalable web sites". In
the tips section, the author mentions using templates to speed things
up.
Generally spoken, this is wrong. Templates _might_ speed things up if
they manage to take a better approach to caching than your application
does otherwise itself.
I was wondering how the template engines manage PHP pages that
contain calls to MySQL: In our application, the data returned is
different for most users, so the resulting page has different
contents. So why do templates (and opcode cache) improve performance?
Because they encourage to split the displayed parts up into logical
entities (say: a catalogue entry) and bring abilities to cache those
fragments that seldom change.

Opcode cache is a completely different beast. It saves the burden of
text (i.e. PHP code) parsing, and may also do some JIT optimizations.

-hwh
Aug 25 '08 #2

P: n/a
On Mon, 25 Aug 2008 12:32:07 +0200, Hans-Werner Hilse <hi***@web.de>
wrote:
>Because they encourage to split the displayed parts up into logical
entities (say: a catalogue entry) and bring abilities to cache those
fragments that seldom change.
Ah OK. So I should split the static parts and the dynamic parts that
make up a page.
>Opcode cache is a completely different beast. It saves the burden of
text (i.e. PHP code) parsing, and may also do some JIT optimizations.
Thanks.
Aug 25 '08 #3

P: n/a
Gilles Ganault <no****@nospam.comwrites:
So why do templates (and opcode cache) improve performance?
Templates improve *programmer* performance by cleanly separating logic
from presentation.

As for improving *program* performance? Not so much. :-)

sherm--

--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
Aug 25 '08 #4

P: n/a
Gilles Ganault wrote:
Hello

I'm no PHP expert, and I'm reading "Building scalable web sites". In
the tips section, the author mentions using templates to speed things
up. I was wondering how the template engines manage PHP pages that
contain calls to MySQL: In our application, the data returned is
different for most users, so the resulting page has different
contents. So why do templates (and opcode cache) improve performance?

Thank you.
Someone argued templates improve "development speed" by separating
logic from presentation. The templating systems all make that
arugment. Well, maybe. Separating logic from content is a worthy design
goal. But you don't necessarily need a templating engine to do that.
file_get_contents() works fine for me.

I spent a few weeks playing with SmartyTemplate once (one of the more
popular templating systems) and I didn't think it was worth the hassle.
the *.tpl files Smarty employs are a pain to work with (difficult to
debug) and it just doesn't buy you anything you couldn't do yourself
with good abstract code design and file_get_contents() for retrieving
html fragments.

Templating systems are great for Java Servlets: you can change html
with a text editor, without recompiling the code. But for interpreted
languages you don't need that anyway.
--
cut the board three times and it's still too short
Aug 25 '08 #5

P: n/a
On Mon, 25 Aug 2008 13:06:14 -0600, sliverdigger
<sl**********@closenuf.netwrote:
>Someone argued templates improve "development speed" by separating
logic from presentation. The templating systems all make that
arugment. Well, maybe. Separating logic from content is a worthy design
goal. But you don't necessarily need a templating engine to do that.
file_get_contents() works fine for me.
Thanks for the input.
Aug 26 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.