From 509c694d4b6f5b0520c630bc0e4be25142fb7603 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Thu, 17 Apr 2014 13:18:47 -0700 Subject: [PATCH] #20614: Fixing cache invalidation between browsers One browser with different headers would invalidate all saved versions for a page, so two clients could be in a position not to get a cached version anytime if requests were alternated. Chrome creates a cache entry, IE creates a cache entry and delete all others, Chrome comes back deletes all entries, IE comes back and has no entries. Work Item: 20614 --- .../Orchard.OutputCache/Filters/OutputCacheFilter.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs index fc8475815..dea8cec14 100644 --- a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs +++ b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs @@ -183,12 +183,6 @@ namespace Orchard.OutputCache.Filters { // different tenants with the same urls have different entries _varyRequestHeaders.Add("HOST"); - // Set the Vary: Accept-Encoding response header. - // This instructs the proxies to cache two versions of the resource: one compressed, and one uncompressed. - // The correct version of the resource is delivered based on the client request header. - // This is a good choice for applications that are singly homed and depend on public proxies for user locality. - _varyRequestHeaders.Add("Accept-Encoding"); - // caches the ignored urls to prevent a query to the settings _ignoredUrls = _cacheManager.Get("CacheSettingsPart.IgnoredUrls", context => { @@ -417,8 +411,8 @@ namespace Orchard.OutputCache.Filters { Logger.Debug("Cache item added: " + _cacheItem.CacheKey); - // remove old cache data - _cacheService.RemoveByTag(_invariantCacheKey); + // remove only the current version of the page + _cacheService.RemoveByTag(_cacheKey); // add data to cache _cacheStorageProvider.Set(_cacheKey, _cacheItem); @@ -463,6 +457,7 @@ namespace Orchard.OutputCache.Filters { null ); + // remove all cached version of the same page _cacheService.RemoveByTag(invariantCacheKey); filterContext.Result = new RedirectResult(redirectUrl, ((RedirectResult) filterContext.Result).Permanent);