mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-26 20:16:15 +08:00
[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:
committed by
Sébastien Ros
parent
dbbeb175a6
commit
35c379191e
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user