From 5ae690b30e3be014fa8125004c7b2418a83a438b Mon Sep 17 00:00:00 2001 From: Simon Hartfield Date: Sun, 2 Feb 2025 12:25:27 +0000 Subject: [PATCH] Set Smidge cachebuster type --- .../RuntimeMinification/SmidgeOptionsSetup.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.Common/RuntimeMinification/SmidgeOptionsSetup.cs b/src/Umbraco.Web.Common/RuntimeMinification/SmidgeOptionsSetup.cs index 37701928c61f..6d4d40f91ca8 100644 --- a/src/Umbraco.Web.Common/RuntimeMinification/SmidgeOptionsSetup.cs +++ b/src/Umbraco.Web.Common/RuntimeMinification/SmidgeOptionsSetup.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Options; +using Smidge.Cache; using Smidge.Options; using Umbraco.Cms.Core.Configuration.Models; @@ -12,11 +13,25 @@ public SmidgeOptionsSetup(IOptions runtimeMinificat => _runtimeMinificatinoSettings = runtimeMinificatinoSettings; /// - /// Configures Smidge to use in-memory caching if configured that way or if certain cache busters are used + /// Configures Smidge to use in-memory caching if configured that way or if certain cache busters are used. As well as the cache buster type. /// /// public void Configure(SmidgeOptions options) - => options.CacheOptions.UseInMemoryCache = _runtimeMinificatinoSettings.Value.UseInMemoryCache || + { + options.CacheOptions.UseInMemoryCache = _runtimeMinificatinoSettings.Value.UseInMemoryCache || _runtimeMinificatinoSettings.Value.CacheBuster == RuntimeMinificationCacheBuster.Timestamp; + + + Type cacheBusterType = _runtimeMinificatinoSettings.Value.CacheBuster switch + { + RuntimeMinificationCacheBuster.AppDomain => typeof(AppDomainLifetimeCacheBuster), + RuntimeMinificationCacheBuster.Version => typeof(UmbracoSmidgeConfigCacheBuster), + RuntimeMinificationCacheBuster.Timestamp => typeof(TimestampCacheBuster), + _ => throw new NotImplementedException(), + }; + + options.DefaultBundleOptions.DebugOptions.SetCacheBusterType(cacheBusterType); + options.DefaultBundleOptions.ProductionOptions.SetCacheBusterType(cacheBusterType); + } }