#20977: Correctly removing cacheItems by invariant tag

WorkItem: 20977
This commit is contained in:
Stanley Goldman
2014-10-14 20:10:24 -04:00
parent af01131879
commit 35823646cf

View File

@@ -418,26 +418,23 @@ namespace Orchard.OutputCache.Filters {
Logger.Debug("Redirect on POST");
var redirectUrl = redirectResult.Url;
if (!VirtualPathUtility.IsAbsolute(redirectUrl)) {
var applicationRoot = new UrlHelper(filterContext.HttpContext.Request.RequestContext).MakeAbsolute("/");
if (redirectUrl.StartsWith(applicationRoot, StringComparison.OrdinalIgnoreCase)) {
redirectUrl = "~/" + redirectUrl.Substring(applicationRoot.Length);
redirectUrl = VirtualPathUtility.ToAbsolute(redirectUrl);
}
if (filterContext.HttpContext.Request.IsLocalUrl(redirectUrl)) {
var helper = new UrlHelper(filterContext.HttpContext.Request.RequestContext);
var absolutePath = new Uri(helper.MakeAbsolute(redirectUrl)).AbsolutePath;
// querystring invariant key
var invariantCacheKey = ComputeCacheKey(
_shellSettings.Name,
absolutePath,
() => _workContext.CurrentCulture,
_themeManager.GetRequestTheme(filterContext.RequestContext).Id,
null
);
// remove all cached version of the same page
_cacheService.RemoveByTag(invariantCacheKey);
}
// querystring invariant key
var invariantCacheKey = ComputeCacheKey(
_shellSettings.Name,
redirectUrl,
() => _workContext.CurrentCulture,
_themeManager.GetRequestTheme(filterContext.RequestContext).Id,
null
);
// remove all cached version of the same page
_cacheService.RemoveByTag(invariantCacheKey);
// adding a refresh key so that the redirection doesn't get restored
// from a cached version on a proxy
// this can happen when using public caching, we want to force the