问题
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