From a3313659c38ceb66fd367b2768d3c88b24d01747 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Sat, 20 Dec 2025 15:39:07 +0100 Subject: [PATCH 1/2] Clear the cacje level published content cache on content type change. --- .../Services/DocumentCacheService.cs | 5 +++++ .../Services/MediaCacheService.cs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs b/src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs index d71afdeeec8e..0d19f23b972d 100644 --- a/src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs +++ b/src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs @@ -344,6 +344,11 @@ public void Rebuild(IReadOnlyCollection contentTypeIds) _databaseCacheRepository.Rebuild(contentTypeIds.ToList()); RebuildMemoryCacheByContentTypeAsync(contentTypeIds).GetAwaiter().GetResult(); scope.Complete(); + + // Clear the entire published content cache. + // It doesn't seem feasible to be smarter about this, as a changed content type could be used for a document, + // an elements within the document, an ancestor or a composition. + _publishedContentCache.Clear(); } public async Task RebuildMemoryCacheByContentTypeAsync(IEnumerable contentTypeIds) diff --git a/src/Umbraco.PublishedCache.HybridCache/Services/MediaCacheService.cs b/src/Umbraco.PublishedCache.HybridCache/Services/MediaCacheService.cs index 9fe3dc5990b2..333a0d8c37a9 100644 --- a/src/Umbraco.PublishedCache.HybridCache/Services/MediaCacheService.cs +++ b/src/Umbraco.PublishedCache.HybridCache/Services/MediaCacheService.cs @@ -291,6 +291,11 @@ public void Rebuild(IReadOnlyCollection contentTypeIds) } scope.Complete(); + + // Clear the entire published content cache. + // It doesn't seem feasible to be smarter about this, as a changed content type could be used for a media item, + // an elements within the media item, an ancestor, or a composition. + _publishedContentCache.Clear(); } public IEnumerable GetByContentType(IPublishedContentType contentType) From f9e6b09a8eeba9d6b89a8794211950a3786263db Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Sat, 20 Dec 2025 16:18:03 +0100 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../Services/DocumentCacheService.cs | 2 +- .../Services/MediaCacheService.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs b/src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs index 0d19f23b972d..b47e6c58c821 100644 --- a/src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs +++ b/src/Umbraco.PublishedCache.HybridCache/Services/DocumentCacheService.cs @@ -347,7 +347,7 @@ public void Rebuild(IReadOnlyCollection contentTypeIds) // Clear the entire published content cache. // It doesn't seem feasible to be smarter about this, as a changed content type could be used for a document, - // an elements within the document, an ancestor or a composition. + // elements within the document, an ancestor or composition. _publishedContentCache.Clear(); } diff --git a/src/Umbraco.PublishedCache.HybridCache/Services/MediaCacheService.cs b/src/Umbraco.PublishedCache.HybridCache/Services/MediaCacheService.cs index 333a0d8c37a9..eeeb22aac857 100644 --- a/src/Umbraco.PublishedCache.HybridCache/Services/MediaCacheService.cs +++ b/src/Umbraco.PublishedCache.HybridCache/Services/MediaCacheService.cs @@ -294,7 +294,7 @@ public void Rebuild(IReadOnlyCollection contentTypeIds) // Clear the entire published content cache. // It doesn't seem feasible to be smarter about this, as a changed content type could be used for a media item, - // an elements within the media item, an ancestor, or a composition. + // elements within the media item, an ancestor, or a composition. _publishedContentCache.Clear(); }