I've been playing around with some performance enhancements in an Umbraco install. One of the option I am playing with is replacing calls to Html.RenderPartial() with calls to Html.CachedPartial(). I started on a 7.1.4 site, but each partial returned a blank. I grabbed a clean 7.1.5 install with the responsive starter kit, and replaced:
After much debugging I discovered it was my mistake, in fact Html.CachedPartial is equivalent to Html.Partial not Html.RenderPartial so you just need to ensure you render like this
"So you can specify to cache by member and/or by page and also specify additional view data to your partial view. However, if your view data is dynamic (meaning it could change per page request) the cached output will still be returned. This same principle applies if the model you are passing in is dynamic. Please be aware of this: if you have a different model or viewData for any page request, the result will be the cached result of the first execution."
Have you considered using Donut caching? I would highly recommend you watch the video of this session from CodeGarden 2014 where several Umbraco caching options (including Donut) are considered in detail.
Thanks Jeavon - I've already seen the video, great video!. In a number of cases use a CDN like CloudFlare ($25/mth) + a publish event handler to purge the CDN cache. But, that said, the ability to cache at multiple layers is always beneficial. It was a great feature of v4, and would be awesome to have as part of v7. Even if you used the ViewDataDictionary as cache keys and not worry about the model, that would be a great outcome... pulling a feature out, especially one that directly impacts performance, is a bit of a worry to me at least...
Html.CachedPartial not working
Hi All!
I've been playing around with some performance enhancements in an Umbraco install. One of the option I am playing with is replacing calls to Html.RenderPartial() with calls to Html.CachedPartial(). I started on a 7.1.4 site, but each partial returned a blank. I grabbed a clean 7.1.5 install with the responsive starter kit, and replaced:
with
in the umbHomePage.cshtml file, and it also returns a blank partial. Any ideas? Anyone got this working?
Cheers!
Hi Karl,
I am also seeing this issue on v7.1.6 and have reported it here.
Jeavon
Hi Karl,
After much debugging I discovered it was my mistake, in fact
Html.CachedPartial
is equivalent toHtml.Partial
notHtml.RenderPartial
so you just need to ensure you render like thisJeavon
I wish I could give u 10 high fives :) Nice work - would be good to get the docs updated perhaps as they seem a little unclear?
Hi Karl,
Have you seen this documentation about caching MVC Partial Views in Umbraco. If not then it can be found here: http://our.umbraco.org/documentation/Reference/Mvc/partial-views#Caching
/Dennis
@Dennis - I had, but had syntax blindness :) I was changing the syntax, but not how I included the call in the page.
One thing that I haven't worked out is how to use the query string as a key in the cache like you could do in the old macros. Is that possible?
Further to this, I've tried to bust the cache as follows:
But this keeps showing the first page of a multiple page result. Surely there is a way to use a param as part of the cache key? Anyone???
Cheers!
Hi Karl,
I don't think so, if you read the last paragraph
"So you can specify to cache by member and/or by page and also specify additional view data to your partial view. However, if your view data is dynamic (meaning it could change per page request) the cached output will still be returned. This same principle applies if the model you are passing in is dynamic. Please be aware of this: if you have a different model or viewData for any page request, the result will be the cached result of the first execution."
Have you considered using Donut caching? I would highly recommend you watch the video of this session from CodeGarden 2014 where several Umbraco caching options (including Donut) are considered in detail.
Jeavon
Thanks Jeavon - I've already seen the video, great video!. In a number of cases use a CDN like CloudFlare ($25/mth) + a publish event handler to purge the CDN cache. But, that said, the ability to cache at multiple layers is always beneficial. It was a great feature of v4, and would be awesome to have as part of v7. Even if you used the ViewDataDictionary as cache keys and not worry about the model, that would be a great outcome... pulling a feature out, especially one that directly impacts performance, is a bit of a worry to me at least...
Having had a good look at how the macro caching works, I think it would be possible to do this. I suggest you raise a feature request on YouTrack.
is working on a reply...