Smarty:如何正确缓存?

编程入门 行业动态 更新时间:2024-10-21 11:48:07
本文介绍了Smarty:如何正确缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

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

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

在整个页面周围放置 nocache 标签?在实际包含动态数据的标记段周围放置nocache 标签?在动态数据周围放置 nocache 标签?以某种方式告诉 Smarty 不要缓存动态数据? 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?

动态数据被分配为 Smarty 变量(例如通过 assign).我想我需要尝试最大化缓存,但我在需要缓存的内容、如何取消缓存、何时缓存、何时取消缓存等方面有些挣扎.

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.

有什么建议吗?

推荐答案

如果您的网站大部分是静态的,那么在显示动态内容的整个代码段周围放置 nocache 标签.

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

相反,如果您网站的每个页面都包含一些动态输出,我建议您在 Smarty 类初始化期间禁用 Smarty 缓存.

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

这篇关于Smarty:如何正确缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 06:44:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1405912.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓存   如何正确   Smarty

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!