Smarty: how to cache properly?

耗尽温柔 提交于 2019-12-24 00:34:40

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/8367355/smarty-how-to-cache-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!