2

Say I have a page that contains dynamic content (e.g. search results). What is the proper caching technique?

  • Put nocache tags around the entire page?
  • Put nocache tags around the segment of mark up that actually contains the dynamic data?
  • Put nocache tags around the dynamic data?
  • Somehow tell Smarty not to cache the dynamic data?

The dynamic data is assigned as a Smarty variable (e.g. via assign). I think I need to try to maximize caching, but am struggling a bit at what needs to be cached, how to un-cache, when to cache, when to un-cache, etc.

Any tips?

StackOverflowNewbie
  • 39,403
  • 111
  • 277
  • 441

1 Answers1

0

If your website is mostly static, then put nocache tag around the entire segment of code that displays the dynamic content.

Instead, if every page of your website contains a bit of dynamic output, I suggest you to disable Smarty caching during Smarty class initialization.

lorenzo-s
  • 16,603
  • 15
  • 54
  • 86
  • Shouldn't I be trying to maximize caching? Almost every page will contain some dynamic content. – StackOverflowNewbie Dec 03 '11 at 12:17
  • If the main content of that pages is dynamic, disable all the cache. If there are only small pieces of dynamic data, but the site is mainly static, use `{nocache}`. Smarty templates are not parsed everytime disabling cache. Smarty templates are only parsed when TPL is modified. Then a PHP "compiled" page is generated. So, don't be afraid about Smarty template parsing overhead. http://www.smarty.net/docs/en/caching.tpl – lorenzo-s Dec 03 '11 at 12:19