Smarty:如何正确缓存?
假设我有一个包含动态内容(例如搜索结果)的页面。什么是正确的缓存技术?
- 在整个页面周围放置
nocache
标签? - 在实际包含动态数据的标记段周围放置
nocache
标记? - 在动态数据周围放置
nocache
标签? - 以某种方式告诉Smarty不要缓存动态数据?
动态数据被分配为Smarty变量(例如通过分配
)。我想我需要尝试最大化缓存,但是在需要缓存什么、如何取消缓存、何时缓存、何时取消缓存等方面有点挣扎。
有什么建议吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的网站大部分是静态的,则在显示动态内容的整个代码段周围放置
nocache
标记。相反,如果您网站的每个页面都包含一些动态输出,我建议您在 Smarty 类初始化期间禁用 Smarty 缓存。
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.