Share » Learn » eZ Publish » eZ Publish Performance Optimization...

eZ Publish Performance Optimization Part 3 of 3: Practical Cache and Template Solutions

Wednesday 24 January 2007 5:05:00 pm

  • Currently 5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

eZ Publish has its own powerful template language. This section looks at a few cases where you can improve site performance by optimizing the templates.

What not to do in templates

The eZ Publish template language should not be treated as a general-purpose programming language. When application logic is added to the template itself it reduces website performance. An example of sub-optimal logic in templates is:

  1. Fetch all articles and users to arrays.
  2. Use a foreach template construct to iterate through all articles to find out which authors have written which articles.
  3. Display the result with another foreach construct for each article.

This scenario is not desirable for the following reasons:

  • Fetching many objects takes up a lot of memory.
  • Fetching large object lists is slow.
  • Doing compare logic on large object sets in the template language is much slower than in PHP or in SQL.

It is bad practice to have logic like this in the template itself. In cases where you find yourself adding more and more logic to the template code, ask yourself whether it can be implemented as a separate module, template operator or as an extension to eZ Publish. Doing the example above in pure SQL with a template operator is many times faster than doing it in the template.

36 542 Users on board!

Tutorial menu

Printable

Printer Friendly version of the full article on one page with plain styles

Author(s)