From 458d06a74e8269595813a7d27563143b2e686504 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Mon, 17 Mar 2014 11:54:53 -0700 Subject: [PATCH] #20555: Don't cache routes with invalid duration Work Item: 20555 --- .../Caching/Output/AzureOutputCacheStorageProvider.cs | 4 ++++ .../Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Orchard.Web/Modules/Orchard.Azure/Services/Caching/Output/AzureOutputCacheStorageProvider.cs b/src/Orchard.Web/Modules/Orchard.Azure/Services/Caching/Output/AzureOutputCacheStorageProvider.cs index 925ba081f..66cb2ac50 100644 --- a/src/Orchard.Web/Modules/Orchard.Azure/Services/Caching/Output/AzureOutputCacheStorageProvider.cs +++ b/src/Orchard.Web/Modules/Orchard.Azure/Services/Caching/Output/AzureOutputCacheStorageProvider.cs @@ -47,6 +47,10 @@ namespace Orchard.Azure.Services.Caching.Output { } public void Set(string key, CacheItem cacheItem) { + if (cacheItem.ValidFor <= 0) { + return; + } + Logger.Debug("Set() invoked with key='{0}' in region '{1}'.", key, _regionAlphaNumeric); _cache.Put(key, cacheItem, TimeSpan.FromSeconds(cacheItem.ValidFor), _regionAlphaNumeric); } diff --git a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs index 53dfd757d..9054c3e29 100644 --- a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs +++ b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs @@ -381,6 +381,10 @@ namespace Orchard.OutputCache.Filters { // default duration of specific one ? var cacheDuration = configuration != null && configuration.Duration.HasValue ? configuration.Duration.Value : _cacheDuration; + if (cacheDuration <= 0) { + return; + } + // include each of the content item ids as tags for the cache entry var contentItemIds = _displayedContentItemHandler.GetDisplayed().Select(x => x.ToString(CultureInfo.InvariantCulture)).ToArray();