diff --git a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs index 9ada76e2b..595f896ed 100644 --- a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs +++ b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs @@ -226,6 +226,12 @@ namespace Orchard.OutputCache.Filters { // To prevent access to the original lifetime scope a new work context scope should be created here and dependencies // should be resolved from it. + // Recheck the response status code incase it was modified before the callback. + if (response.StatusCode != 200) { + Logger.Debug("Response for item '{0}' will not be cached because status code was set to {1} during rendering.", _cacheKey, response.StatusCode); + return; + } + using (var scope = _workContextAccessor.CreateWorkContextScope()) { var cacheItem = new CacheItem() { CachedOnUtc = _now,