#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
This commit is contained in:
Sebastien Ros
2014-04-17 13:18:47 -07:00
parent e5d89ea1fb
commit 509c694d4b

View File

@@ -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);