Re: [phplib] Compiled templates vs. parsed From: Maxim Derkachev (kot <email protected>)
Date: 03/28/01

Hello Andreas,

Tuesday, March 27, 2001, 8:09:04 PM, you wrote:

AA> The layout defined by the templates does not change - so why parse it every
AA> hit?
Because while the layout does not change, the data does change.

AA> I think it would be much more effective to compile the templates into mixed
AA> php-code (for runtime), that runs much faster. Smarty does this very well,
AA> but couldn't it be a feauture of PHPlib?

The approach would work if the data does not change. So why use any of the template
engine if you could use plain HTML in this case? It's damn fast! :)

AA> Another approach (the best I think) is to compile the templates directly to
AA> plain HTML and include the html. Well this is a bit tricky, 'caus not only
AA> if the templates change, also if database records change, the templates have
AA> to be recompiled.
Right.

AA> The time-overhead to check for changes is minimal compared
AA> to parsing and accessing the database for each and every hit. For big sites
AA> this is very cool, since the load on the database is reduced to a minimum.

Wrong. You'll need to hit the db the same way to check if the changes
has occurred. Thus, it does not reduce database accesses and some computations (some of
the data you publish may not be in a database, but is computed from
other sources) - you'll need to know if the data has changed.
With this approach you could only reduce an overhead by avoiding the template parse stage.
In some cases it would even increase overhead, because you often don't
check values from the db while parsing - you just assign them to the
template variables. But if you check if the data has changed - you
should place the old data somewhere to compare the new data against
the old one for changes, and provide some functionality to for the
check.

-- 
Best regards,
Maxim Derkachev mailto:kot <email protected>
Symbol-Plus Publishing Ltd.
phone: +7 (812) 324-53-53
http://www.Books.Ru -- All Books of Russia
 

--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>