智能缓存如何工作?(How does smarty cache work? How does it know when to cache?)

编程入门 行业动态 更新时间:2024-10-23 23:23:49
智能缓存如何工作?(How does smarty cache work? How does it know when to cache?)

是什么让smarty决定它的缓存是否足够或是否需要重新创建它? $ _REQUEST会这样做吗? 或者所有全局变量包括cookie,会话等... index.php和index.php?task = home具有相同的缓存,那么cookie和会话信息呢? 它是如何工作的? 我有一个网站,我想最大限度地缓存,但我甚至不知道缓存是如何工作的,他们没有解释smarty网站上的内部。

回答罗德尼可能有助于理解我的问题:我有兴趣知道smarty是否将动态代码转换为静态html,如:smarty.net/docs/en/language.function.nocache.tpl,如果是,何时以及如何它决定缓存是好还是坏。 所以,如果我有Hello {$ user-> username}! 它会显示Hello Rodney To Brad,因为当brad看到页面时它会缓存吗?

What makes smarty decide if the cache it has is sufficient or if it needs to recreate it? Will the $_REQUEST do? Or all globals including cookies, session and etc... Is index.php and index.php?task=home have the same cache, what about cookies and session info? How does it work? I have a site that I want to cache to the maximum potential but I don't even know how the cache works and they don't explain the internals on the smarty website.

Answer To Rodney that might be helpful in understanding my question: I'm interested in knowing if smarty turns dynamic code into static html as in: smarty.net/docs/en/language.function.nocache.tpl and if so when and how does it decide that the cache is good or bad. so if I had Hello {$user->username}! would it show the Hello Rodney To Brad because it cached it when brad was looking at the page?

最满意答案

阅读有关缓存的文档。

如果无法找到缓存或已超过其生命周期,Smarty决定重新执行模板。 $cache_id是一个聪明的值,使其专门为$cache_id保存缓存

UPDATE

控制输出的可缓存性部分解释了智能如何处理静态缓存中的动态内容。 该页面回答了有关“Rodney”和“Brad”的问题,这些问题是注入到模板缓存渲染中的动态值。

read the docs on Caching.

Smarty decides to re-execute a template if a cache cannot be found, or has exceeded its lifetime. $cache_id is a value one passes smarty to make it save the cache specifically for $cache_id

UPDATE

The section Controlling Cacheability of Output explains how smarty can handle dynamic content within static caches. That page answers your question regarding "Rodney" and "Brad" being dynamic values injected into the cached rendering of the template.

更多推荐

本文发布于:2023-08-07 20:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465963.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓存   智能   工作   work   cache

发布评论

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

>www.elefans.com

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