diff --git a/src/Umbraco.Tests/TypeHelperTests.cs b/src/Umbraco.Tests/TypeHelperTests.cs index 93bde4439c..f637b1ff20 100644 --- a/src/Umbraco.Tests/TypeHelperTests.cs +++ b/src/Umbraco.Tests/TypeHelperTests.cs @@ -8,6 +8,7 @@ using NUnit.Framework; using Umbraco.Core; using Umbraco.Tests.PartialTrust; using Umbraco.Web; +using Umbraco.Web.Cache; using UmbracoExamine; using umbraco; using umbraco.presentation; @@ -67,7 +68,7 @@ namespace Umbraco.Tests var t6 = TypeHelper.GetLowestBaseType(typeof (IApplicationEventHandler), typeof (LegacyScheduledTasks), - typeof(CacheHelperExtensions.CacheHelperApplicationEventListener)); + typeof(CacheRefresherEventHandler)); Assert.IsTrue(t6.Success); Assert.AreEqual(typeof(IApplicationEventHandler), t6.Result); diff --git a/src/Umbraco.Web/Cache/MediaCacheRefresher.cs b/src/Umbraco.Web/Cache/MediaCacheRefresher.cs index 2536165057..53abacc7a5 100644 --- a/src/Umbraco.Web/Cache/MediaCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/MediaCacheRefresher.cs @@ -111,6 +111,8 @@ namespace Umbraco.Web.Cache { if (payloads == null) return; + ApplicationContext.Current.ApplicationCache.ClearPartialViewCache(); + payloads.ForEach(payload => { foreach (var idPart in payload.Path.Split(',')) diff --git a/src/Umbraco.Web/Cache/MemberCacheRefresher.cs b/src/Umbraco.Web/Cache/MemberCacheRefresher.cs index 4780a9e502..8f6437c8b6 100644 --- a/src/Umbraco.Web/Cache/MemberCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/MemberCacheRefresher.cs @@ -44,6 +44,8 @@ namespace Umbraco.Web.Cache private void ClearCache(int id) { + ApplicationContext.Current.ApplicationCache.ClearPartialViewCache(); + ApplicationContext.Current.ApplicationCache. ClearCacheByKeySearch(string.Format("{0}_{1}", CacheKeys.MemberLibraryCacheKey, id)); ApplicationContext.Current.ApplicationCache. diff --git a/src/Umbraco.Web/Cache/PageCacheRefresher.cs b/src/Umbraco.Web/Cache/PageCacheRefresher.cs index 366607afd2..8845d61657 100644 --- a/src/Umbraco.Web/Cache/PageCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/PageCacheRefresher.cs @@ -1,4 +1,5 @@ using System; +using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Models; using Umbraco.Core.Sync; @@ -60,6 +61,7 @@ namespace Umbraco.Web.Cache /// The id. public override void Refresh(int id) { + ApplicationContext.Current.ApplicationCache.ClearPartialViewCache(); content.Instance.UpdateDocumentCache(id); DistributedCache.Instance.ClearAllMacroCacheOnCurrentServer(); DistributedCache.Instance.ClearXsltCacheOnCurrentServer(); @@ -72,6 +74,7 @@ namespace Umbraco.Web.Cache /// The id. public override void Remove(int id) { + ApplicationContext.Current.ApplicationCache.ClearPartialViewCache(); content.Instance.ClearDocumentCache(id); DistributedCache.Instance.ClearAllMacroCacheOnCurrentServer(); DistributedCache.Instance.ClearXsltCacheOnCurrentServer(); @@ -80,6 +83,7 @@ namespace Umbraco.Web.Cache public override void Refresh(IContent instance) { + ApplicationContext.Current.ApplicationCache.ClearPartialViewCache(); content.Instance.UpdateDocumentCache(new Document(instance)); DistributedCache.Instance.ClearAllMacroCacheOnCurrentServer(); DistributedCache.Instance.ClearXsltCacheOnCurrentServer(); @@ -88,6 +92,7 @@ namespace Umbraco.Web.Cache public override void Remove(IContent instance) { + ApplicationContext.Current.ApplicationCache.ClearPartialViewCache(); content.Instance.ClearDocumentCache(new Document(instance)); DistributedCache.Instance.ClearAllMacroCacheOnCurrentServer(); DistributedCache.Instance.ClearXsltCacheOnCurrentServer(); diff --git a/src/Umbraco.Web/CacheHelperExtensions.cs b/src/Umbraco.Web/CacheHelperExtensions.cs index 780f841190..0dfed94888 100644 --- a/src/Umbraco.Web/CacheHelperExtensions.cs +++ b/src/Umbraco.Web/CacheHelperExtensions.cs @@ -18,32 +18,6 @@ namespace Umbraco.Web /// internal static class CacheHelperExtensions { - /// - /// Application event handler to bind to events to clear the cache for the cache helper extensions - /// - internal sealed class CacheHelperApplicationEventListener : ApplicationEventHandler - { - protected override void ApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) - { - if (applicationContext != null) - { - //bind to events to clear the cache, after publish, after media save and after member save - - Document.AfterPublish - += (sender, args) => - applicationContext.ApplicationCache.ClearPartialViewCache(); - - global::umbraco.cms.businesslogic.media.Media.AfterSave - += (sender, args) => - applicationContext.ApplicationCache.ClearPartialViewCache(); - - global::umbraco.cms.businesslogic.member.Member.AfterSave - += (sender, args) => - applicationContext.ApplicationCache.ClearPartialViewCache(); - } - } - - } public const string PartialViewCacheKey = "Umbraco.Web.PartialViewCacheKey"; diff --git a/src/Umbraco.Web/WebBootManager.cs b/src/Umbraco.Web/WebBootManager.cs index 31d3ce42ed..a75b9a2bcd 100644 --- a/src/Umbraco.Web/WebBootManager.cs +++ b/src/Umbraco.Web/WebBootManager.cs @@ -116,7 +116,6 @@ namespace Umbraco.Web protected override void InitializeApplicationEventsResolver() { base.InitializeApplicationEventsResolver(); - ApplicationEventsResolver.Current.AddType(); ApplicationEventsResolver.Current.AddType(); //We need to remove these types because we've obsoleted them and we don't want them executing: ApplicationEventsResolver.Current.RemoveType();