Set WeberTrivia.com to be my default homepage.   Suggest a Question                                               

Suggest A Question : :  Frequently Asked Questions : :  Search : :  Relevant Manuals : : 
PHP Questions : :  Linux Questions : :  MySQL Questions : : 
home  [ Login ] 

Introduction - cache

Introduction - cache -- How Sigma caches the "prepared" templates

Cache FAQ

1. What exactly is this cache feature?
2. What about data?
3. Is the cached version regenerated when the template changes?
4. Is there any TTL setting?
5. Any way to flush the cache?
6. Does this give significant performance gains?

1. What exactly is this cache feature?

This is the way to bypass RegExp parsing on template load. Instead of parsing the original template on every request, we keep its internal representation (a serialized array, essentially) and load it instead.

Think about template compilation in Smarty. Only Sigma does not compile templates to PHP code.

2. What about data?

No data caching is taking place. If you want to do this, consider using some of the PEAR's cache packages.

3. Is the cached version regenerated when the template changes?

Yes.

4. Is there any TTL setting?

No. Cached version is considered valid until the source template changes.

5. Any way to flush the cache?

Yes, just delete all the files in the cache dir.

6. Does this give significant performance gains?

Yes. The answer is based on personal experience.

If you are going to perform some benchmarks, then use some real-world complex templates, not artificial ones. The performance gain will be greater with bigger and more complex (dozens of blocks) ones.

Cache usage

Caching is completely transparent. To take advantage of this feature you only have to either pass a second parameter to the constructor or call a setCacheRoot() method later.

<?php require_once 'HTML/Template/Sigma.php';  $tpl =& new HTML_Template_Sigma('./templates', './templates/prepared');  $tpl->loadTemplateFile('default.html');  // go on  ?>

For each distinct template file in ./templates loaded with either loadTemplatefile(), addBlockfile(), replaceBlockfile() or <!-- INCLUDE --> a prepared version will be generated in ./templates/prepared.

Who's Online
Guest Users: 12
Google
Web
WeberTrivia
WeberDev
WeberForums
 Free Sample Chapters  Free Sample Chapters
  Deliver First Class Web Sites: 101 Essential Checklists
Want to learn how to make your web sites usable and accessible? Want to ensure that your sites meet current best practice, without spending hours trawling through incomprehensible specifications and recommendations from dozens of different books, research papers, and web sites? Want to make sure that the sites you build are "right the first time," requiring no costly redevelopments?

More Sample Chapters

PHP General