Kentico 中的部分缓存依赖项

发布于 2024-12-03 16:18:46 字数 1206 浏览 0 评论 0原文

如何在 Kentico CMS 中使用部分依赖项缓存?

这是我需要的一个非常常见的示例,但无法弄清楚如何正确设置具有依赖项的部分缓存(在门户模式下,尽管我认为这也应该适用于其他开发模式):

  • /Home(带中继器)
  • /新闻
    • 项目 1(因此路径 = /News/Item-1)
    • 项目 2(因此路径 = /News/Item-2)

主页有一个中继器 Web 部件,其中列出了最新的新闻项目。它的路径为“/%”,文档类型过滤器设置为“CMS.News”;显然还有一个“部分缓存分钟”值> 0.没有自定义代码;只是门户 Web 部件和标准文档类型。

我应该使用的确切“部分缓存依赖项”字符串是什么,以便当第三个新闻项时它立即反映在主页上,但否则使用缓存?

Kentico 确实发布了几篇博客文章,包括 Deep div:缓存依赖项,但我很难将那里讨论的理论应用到网站上。我什至在评论中问了一些问题,但 Kentico 支持人员的回答并没有真正的帮助。

从我在那篇文章中可以看出,他们说使用 node|%CurrentSite.SiteName%}|/News|childnodes ,它似乎有一些神奇的关键字,如 node 和一些宏元素,例如 {%CurrentSite.SiteName%}。 (我知道所有项目都需要小写,所以我已经知道他们的建议并不真正一致。它至少应该是 node|%CurrentSite.SiteName%}|/news|childnodes 。我需要在宏上强制使用小写吗?)首先,该字符串对我不起作用 - 它仍在缓存主页热门新​​闻转发器(是的,全页缓存已关闭);其次,如何构建这样的字符串并调试它应该是什么?链接的帖子确实有一系列示例,但它(对我来说)令人困惑并且并不详尽。

任何人都可以在任何地方提供一个很好的示例或更好的博客文章参考来以另一种方式解释这一点吗?

编辑:我意识到我问这个问题相当广泛。如果我们缩小范围,只回答这个问题:如何确定使用哪些设置来缓存依赖于另一个文件夹中的更改的转发器?

How do I use the partial dependency caching in Kentico CMS?

Here's a very common example need I have but can't figure how to set up partial caching with dependencies correctly (in Portal mode, though I think this should apply to the other development modes too):

  • /Home (with a Repeater)
  • /News
    • Item 1 (so path = /News/Item-1)
    • Item 2 (so path = /News/Item-2)

The Home page has a Repeater web part that lists the most recent news items. It has a Path of "/%" and Document Types filter set to "CMS.News"; obviously also a "Partial cache minutes" value > 0. There is no custom code; just Portal web parts and standard document types.

What is the exact "Partial cache dependencies" string I should use so that when a third news item it is immediately reflected on the Home page, but otherwise uses the cache?

Kentico did release several blog posts including Deep dive: Cache dependencies, but I'm having difficulty applying the theory discussed there to a site. I even asked in comments there some questions, but the answers by the Kentico support there weren't really helpful.

From what I could tell in that post, they said to use node|%CurrentSite.SiteName%}|/News|childnodes which seems to have some magic keywords like node and some macro elements like {%CurrentSite.SiteName%}. (I know that all items need to be lowercase, so already I know their advice isn't real consistent. It should at least be node|%CurrentSite.SiteName%}|/news|childnodes instead. And do I need to force lowercase on the macros?) First of all, that string didn't work for me--it was still caching the Home page Top News repeater (yes, full page caching was turned off); second, how do I build a string like that and debug what it should be? The linked post does have a grid of examples, but it is confusing (to me) and not exhaustive.

Can anyone provide a good example or better blog post reference anywhere that explains this in another way?

EDIT: I realized I asked this question fairly broadly. How about if we narrow it to just answer the question: How do I determine what settings to use to cache a repeater with a dependency to changes in another folder?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

绾颜 2024-12-10 16:18:46

您在帖子中提到的魔法词基本上是特定对象的关键字。您可以在缓存选项描述中看到它们列出 - “节点”、“节点”、“nodeid”被列为最常用的节点处理方式。但下面描述了任何对象的语法,您将在其中使用该对象类名称。

关于 Kentico 首席技术官的博客文章和他在评论中的回答,看起来他忽略或误解了你的问题。您正在谈论部分缓存,而他正在为您提供有关“正常”缓存设置的示例。触摸键中的宏在所有其他缓存设置中得到解析(大小写无关),但在部分缓存中则不然。该功能将在即将发布的 6.0 版本中提供。

因此,现在您必须在触摸键缓存设置中对站点名称进行硬编码。

The magic words you mentioned in your post are basically the keywords for particular objects. You can see them listed in the caching options description - the "node", "nodes", "nodeid" are listed there as most common for working with nodes. But below then is described the syntax for any object, where you will use that object class name.

Regarding the blog post from the Kentico's CTO and his answers in the comments, it looks like he overlooked or misunderstood your question. you are talking about partial caching and he was giving you examples on the "normal" caching settings. Macros in the touch keys are resolved (lower case or upper case does not matter) in all other caching settings but not in the partial caching. This feature will be available in the upcoming version 6.0.

So, right now you have to hard-code the site name in the touch key cache setting.

赏烟花じ飞满天 2024-12-10 16:18:46

我打开了缓存调试并查看了正在生成的缓存名称。我看到我的被设置为...

node|{%CurrentSite.SiteName%}|/test-section/|childnodes

...这显然是不正确的并且永远不会工作!

看起来宏没有在部分缓存依赖项属性中得到解析。因此,您不能使用“{%CurrentSite.SiteName%}”代替网站名称。这是对我有用的部分缓存依赖项的示例...

node|mytestsite|/test-section/|childnodes

使用上面的部分缓存依赖项,一旦我删除,缓存就会刷新一个子项目。

I turned on the cache debugging and looked at what cache names were being generated. I saw mine being set to...

node|{%CurrentSite.SiteName%}|/test-section/|childnodes

...which was obviously incorrect and would never work!

It looks like macros do not get resolved within the Partial Cache Dependencies property. So you can't use "{%CurrentSite.SiteName%}" in place of the site name. Here is an example of a partial cache dependency that worked for me...

node|mytestsite|/test-section/|childnodes

Using the above partial cache dependecy, the cache was refreshed as soon as I deleted a sub-item.

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