[Fixes #7034] Don't cache pages when status code is changed in the view

* Fixed the output caching of non 200 responses when errors are thrown in views

* Added debug message to output cache when the response isn't cached due to a non 200 status code.
This commit is contained in:
Carl Woodhouse
2016-07-21 20:17:33 +01:00
committed by Sébastien Ros
parent dbbeb175a6
commit 35c379191e

View File

@@ -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,