diff --git a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs index f93e4c855..a44a443e3 100644 --- a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs +++ b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs @@ -11,12 +11,14 @@ using System.Threading; using System.Web; using System.Web.Mvc; using System.Web.Routing; +using System.Web.UI; using Orchard.Caching; using Orchard.ContentManagement; using Orchard.Environment.Configuration; using Orchard.Logging; using Orchard.Mvc.Extensions; using Orchard.Mvc.Filters; +using Orchard.OutputCache.Helpers; using Orchard.OutputCache.Models; using Orchard.OutputCache.Services; using Orchard.Services; @@ -263,7 +265,7 @@ namespace Orchard.OutputCache.Filters { var controllerAttributes = filterContext.ActionDescriptor.ControllerDescriptor.GetCustomAttributes(typeof(OutputCacheAttribute), true); var outputCacheAttribute = actionAttributes.Concat(controllerAttributes).Cast().FirstOrDefault(); if (outputCacheAttribute != null) { - if (outputCacheAttribute.Duration <= 0 || outputCacheAttribute.NoStore) { + if (outputCacheAttribute.Duration <= 0 || outputCacheAttribute.NoStore || outputCacheAttribute.IsLocationAnyOf(OutputCacheLocation.Downstream, OutputCacheLocation.Client, OutputCacheLocation.None)) { Logger.Debug("Request for item '{0}' ignored based on OutputCache attribute.", _cacheKey); return false; } diff --git a/src/Orchard.Web/Modules/Orchard.OutputCache/Helpers/OutputCacheAttributeExtensions.cs b/src/Orchard.Web/Modules/Orchard.OutputCache/Helpers/OutputCacheAttributeExtensions.cs new file mode 100644 index 000000000..b34a16b8c --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.OutputCache/Helpers/OutputCacheAttributeExtensions.cs @@ -0,0 +1,14 @@ +using System.Linq; +using System.Web.Mvc; +using System.Web.UI; + +namespace Orchard.OutputCache.Helpers { + public static class OutputCacheAttributeExtensions { + /// + /// Returns true if the Location of the specified output cache attribute matches any of the specified list of locations. + /// + public static bool IsLocationAnyOf(this OutputCacheAttribute attribute, params OutputCacheLocation[] locations) { + return locations.Any(x => attribute.Location == x); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.OutputCache/Orchard.OutputCache.csproj b/src/Orchard.Web/Modules/Orchard.OutputCache/Orchard.OutputCache.csproj index 41e412c22..8a7429e9e 100644 --- a/src/Orchard.Web/Modules/Orchard.OutputCache/Orchard.OutputCache.csproj +++ b/src/Orchard.Web/Modules/Orchard.OutputCache/Orchard.OutputCache.csproj @@ -102,6 +102,7 @@ +