Smarty:如何正确缓存?

发布于 2024-12-19 06:06:25 字数 338 浏览 6 评论 0原文

假设我有一个包含动态内容(例如搜索结果)的页面。什么是正确的缓存技术?

  • 在整个页面周围放置 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Bonjour°[大白 2024-12-26 06:06:25

如果您的网站大部分是静态的,则在显示动态内容的整个代码段周围放置 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文