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 s开发者_开发百科ome 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?
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.
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.
精彩评论