diff --git a/src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureExtensions.cs b/src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureExtensions.cs index bc18a7e63..77ed4665d 100644 --- a/src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureExtensions.cs +++ b/src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureExtensions.cs @@ -335,7 +335,12 @@ private static IServiceCollection ConfigureFusionCache(this IServiceCollection s JitterMaxDuration = settings.JitterMaxDuration, EagerRefreshThreshold = settings.EagerRefreshThreshold, - SkipMemoryCache = settings.SkipMemoryCache + SkipMemoryCache = settings.SkipMemoryCache, + + // This will stop deserialization exceptions to be re-thrown, which will cause the factory to run as if + // the cache entry was not found. This avoids crashes which otherwise would happen if entities that + // are cached are changed in a way that makes them incompatible with the cached version. + ReThrowSerializationExceptions = false }) .WithRegisteredSerializer() // If Redis is disabled (eg. in local development or non-web runtimes), we must instruct FusionCache to