Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
We're having some performance problems with our site, and we played around with caching some of our "expensive" partials with CachedPartial() - and noticed it seemed to provide some significant improvement in page load times.
Just wondered if I could ask a couple of questions about this before we implement?
We have set the cacheByPage option to true, and also introduced our own logic in to the contextualKeyBuilder property - because some of the partial views are used across multiple pages, and have content that may differ depending on language.
My question is are these two cache key properties combined? (i.e. when building the cache key, does it use the page Url and the contextualKeyBuilder argument - or does one override the other?)
Also, when cacheByPage is true - does the cache key include the full Url (including the domain), or is it based on something like the page node Id?
You can see the implementation of CachedPartial here:
and how the Cache Key is built up.
If Cache By Page is turned on, then this will be combined in the Cache key with your ContextualKeyBuilder logic.
With Cache By Page turned on it is only using the Id of the page and not the Url in they key.
(Probably an oversight from when variants was introduced, eg the cache key should include the culture string too! - I made a similar fix for Macros: https://github.com/umbraco/Umbraco-CMS/pull/7555/files - we probably need to do the same for partials!)
Anyway in the meantime, if you include the current culture in your contextual key, combined with the id from the Cache By Page being set to true, that will probably cover your needs?
Thank you Marc.
We've added our own custom key which includes culture (and because we're using nested content/content blocks - the appropriate key for the content block).
Although in-page - many of our partial views are actually rendered via a surface controller for maintainability purposes (i.e. so the logic is all in the controller, leaving the view files just for presentation). So I've also been working on how to cache them (and more importantly, how to clear that cache after a publish event) - successfully so far.
Now to see whether it helps with performance and stability :)
Cool, fingers crossed!
I put a new PR here so that CachedPartial should always cache by culture... as I can see it would be an easy mistake to make on a site with variants...
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted