Use a templating engine


Templating engines, like Smarty and Twig, almost always provide a system for caching compiled templates in a binary file containing an intermediate code called bytecode.
This often considerably reduces CPU usage, especially when an intermediate code cache is added to the templating engine’s cache system.

To enable caching in Smarty:

$smarty = new Smarty;
$smarty->caching = 1;
This best practice should only be applied if it is coherent with your project's specifications.
Under CC-By-NX-SA license