diff --git a/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs b/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs index 6be3dbde92..e8b58ba4bb 100644 --- a/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs @@ -220,8 +220,7 @@ namespace Umbraco.Web.Cache if (payloads.Any(x => x.Type == typeof(IContentType).Name) && !payloads.All(x => x.IsNew)) //if they are all new then don't proceed { - //we need to clear the routes cache here! - //TODO: Is there a better way to handle this without casting ? + //we need to clear the routes cache here! var contentCache = PublishedContentCacheResolver.Current.ContentCache as PublishedContentCache; if (contentCache != null) { diff --git a/src/Umbraco.Web/Cache/DomainCacheRefresher.cs b/src/Umbraco.Web/Cache/DomainCacheRefresher.cs index b2a4a2920f..49d7870585 100644 --- a/src/Umbraco.Web/Cache/DomainCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/DomainCacheRefresher.cs @@ -1,6 +1,8 @@ using System; using Umbraco.Core; using Umbraco.Core.Cache; +using Umbraco.Web.PublishedCache; +using Umbraco.Web.PublishedCache.LegacyXmlCache; namespace Umbraco.Web.Cache { @@ -26,14 +28,25 @@ namespace Umbraco.Web.Cache public override void Refresh(int id) { - ApplicationContext.Current.ApplicationCache.ClearCacheItem(CacheKeys.DomainCacheKey); + ClearCache(); base.Refresh(id); } public override void Remove(int id) { - ApplicationContext.Current.ApplicationCache.ClearCacheItem(CacheKeys.DomainCacheKey); + ClearCache(); base.Remove(id); } + + private void ClearCache() + { + ApplicationContext.Current.ApplicationCache.ClearCacheItem(CacheKeys.DomainCacheKey); + //we need to clear the routes cache here! + var contentCache = PublishedContentCacheResolver.Current.ContentCache as PublishedContentCache; + if (contentCache != null) + { + contentCache.RoutesCache.Clear(); + } + } } } \ No newline at end of file diff --git a/src/Umbraco.Web/PublishedCache/LegacyXmlCache/RoutesCache.cs b/src/Umbraco.Web/PublishedCache/LegacyXmlCache/RoutesCache.cs index c3d0249ea3..7c9bc7e949 100644 --- a/src/Umbraco.Web/PublishedCache/LegacyXmlCache/RoutesCache.cs +++ b/src/Umbraco.Web/PublishedCache/LegacyXmlCache/RoutesCache.cs @@ -49,13 +49,6 @@ namespace Umbraco.Web.PublishedCache.LegacyXmlCache global::umbraco.content.AfterUpdateDocumentCache += (sender, e) => Clear(); global::umbraco.content.AfterClearDocumentCache += (sender, e) => Clear(); - // domains - whenever a domain change we must clear the cache - // because routes contain the id of root nodes of domains - // TODO could we do partial updates instead of clearing the whole cache? - global::umbraco.cms.businesslogic.web.Domain.AfterDelete += (sender, e) => Clear(); - global::umbraco.cms.businesslogic.web.Domain.AfterSave += (sender, e) => Clear(); - global::umbraco.cms.businesslogic.web.Domain.New += (sender, e) => Clear(); - // FIXME // the content class needs to be refactored - at the moment // content.XmlContentInternal setter does not trigger any event