U4-2879 - CachedPartial cache does not clear in load balanced environment

Created by Tom Fulton 17 Sep 2013, 16:34:10 Updated by Shannon Deminick 26 Jun 2017, 05:40:42

I'm using this syntax to create a cached partial (no macro): @Html.CachedPartial("~/Views/Partials/Homepage/MyFile.cshtml", Model, 3600) When I change some content and Publish, the partial updates immediately on the admin node. However, on the other nodes, the partial remains in its cached state until it expires.

There don't seem to be any errors in the log file, and non-macro content seems to refresh just fine.


Tom Fulton 18 Sep 2013, 06:21:20

FYI - can work around this by using a proper Macro and @Umbraco.RenderMacro() instead

Dan Booth 13 Feb 2014, 20:04:23

I've just come across the same issue. Can it really be true that the partial cache isn't cleared in load balanced environments?! After all, the chances are if you are using load balancing you are trying to optimise performance, and not being able to use partial caching totally negates that.

Is there any work around? I don't really want to turn everything into macros. Is there a method that can be called to clear the cache?

Niels Damkjær 17 Feb 2014, 13:52:06

I' have also just had this issue in a Load-balanced environment. Going back to old macros is not an option. We would have to re-code the entire site. Please fix this or provide a workaround.

Is this related to this: http://issues.umbraco.org/issue/U4-3193

Dan Booth 17 Feb 2014, 15:10:20

I think I found a "hacky" way around this.

You need to register a custom event in OnApplicationStarted that registers PageCacheRefresher.CacheUpdated event

eg. public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { PageCacheRefresher.CacheUpdated += PageCacheRefresher_CacheUpdated; }

Then in the CacheUpdated event you can clear the cache using:

void PageCacheRefresher_CacheUpdated(PageCacheRefresher sender, Umbraco.Core.Cache.CacheRefresherEventArgs e) { ApplicationContext.Current.ApplicationCache.ClearCacheByKeySearch("Umbraco.Web.PartialViewCacheKey"); }

I got this through digging through the source. It seems to work, though I've no idea how reliable or robust it is. It would be much better if this was just done automatically.

Andy Dyton 18 Aug 2014, 14:29:59

@Dan.Booth Was the fix you suggested reliable? Wondering whether it's worth testing out.

Dan Booth 18 Aug 2014, 18:23:15

Yeah, it was reliable in 6.16. Though the issue is fixed in 6.21 so I would just upgrade to that.

Shannon Deminick 26 Jun 2017, 05:40:43

Closing issue due to inactivity - see blog post for details https://umbraco.com/blog/issue-tracker-cleanup/

Priority: Normal

Type: Bug

State: Closed


Difficulty: Normal

Category: Architecture

Backwards Compatible: True

Fix Submitted:

Affected versions: 6.1.5

Due in version:


Story Points: