Improving output cache filter.

- This change allows any shapes to be added to the Messages zone without causing the output cache to not kick in anymore.
- Using INotifier instead of INotificationManager to prevent invocation of INotificationProvider implementations.
This commit is contained in:
Sipke Schoorstra
2014-09-30 15:33:14 -07:00
parent 47a00df9d7
commit 69d1ef8f86

View File

@@ -19,6 +19,7 @@ using Orchard.Mvc.Filters;
using Orchard.Services;
using Orchard.Themes;
using Orchard.UI.Admin;
using Orchard.UI.Notify;
using Orchard.Utility.Extensions;
using System.Collections.Specialized;
using Orchard.OutputCache.ViewModels;
@@ -39,6 +40,7 @@ namespace Orchard.OutputCache.Filters {
private readonly ISignals _signals;
private readonly ShellSettings _shellSettings;
private readonly ICacheControlStrategy _cacheControlStrategy;
private readonly INotifier _notifier;
TextWriter _originalWriter;
StringWriter _cachingWriter;
@@ -57,8 +59,9 @@ namespace Orchard.OutputCache.Filters {
ICacheService cacheService,
ISignals signals,
ShellSettings shellSettings,
ICacheControlStrategy cacheControlStrategy
) {
ICacheControlStrategy cacheControlStrategy,
INotifier notifier) {
_cacheManager = cacheManager;
_cacheStorageProvider = cacheStorageProvider;
_tagCache = tagCache;
@@ -70,6 +73,7 @@ namespace Orchard.OutputCache.Filters {
_signals = signals;
_shellSettings = shellSettings;
_cacheControlStrategy = cacheControlStrategy;
_notifier = notifier;
Logger = NullLogger.Instance;
}
@@ -343,9 +347,7 @@ namespace Orchard.OutputCache.Filters {
}
// don't cache the result if there were some notifications
// notifications can come from Notifier and NotificationProvider
var messagesZone = _workContextAccessor.GetContext(filterContext).Layout.Zones["Messages"] as Shape;
if (messagesZone != null && messagesZone.Items.Any()) {
if (_notifier.List().Any()) {
return;
}