From b2ffe4b685fa9e937d69a9a5ea5bb59f74c9b831 Mon Sep 17 00:00:00 2001 From: avs099 Date: Thu, 8 Nov 2018 19:48:16 -0500 Subject: [PATCH] Update ContentFinderByRedirectUrl.cs --- .../Routing/ContentFinderByRedirectUrl.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs b/src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs index c6af13e874..24ef7fb0e1 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs @@ -29,14 +29,6 @@ namespace Umbraco.Web.Routing var service = contentRequest.RoutingContext.UmbracoContext.Application.Services.RedirectUrlService; var redirectUrl = service.GetMostRecentRedirectUrl(route); - // From: http://stackoverflow.com/a/22468386/5018 - // See http://issues.umbraco.org/issue/U4-8361#comment=67-30532 - // Setting automatic 301 redirects to not be cached because browsers cache these very aggressively which then leads - // to problems if you rename a page back to it's original name or create a new page with the original name - contentRequest.Cacheability = HttpCacheability.NoCache; - contentRequest.CacheExtensions = new List { "no-store, must-revalidate" }; - contentRequest.Headers = new Dictionary { { "Pragma", "no-cache" }, { "Expires", "0" } }; - if (redirectUrl == null) { LogHelper.Debug("No match for route: \"{0}\".", () => route); @@ -54,6 +46,15 @@ namespace Umbraco.Web.Routing LogHelper.Debug("Route \"{0}\" matches content {1} with url \"{2}\", redirecting.", () => route, () => content.Id, () => url); + + // From: http://stackoverflow.com/a/22468386/5018 + // See http://issues.umbraco.org/issue/U4-8361#comment=67-30532 + // Setting automatic 301 redirects to not be cached because browsers cache these very aggressively which then leads + // to problems if you rename a page back to it's original name or create a new page with the original name + contentRequest.Cacheability = HttpCacheability.NoCache; + contentRequest.CacheExtensions = new List { "no-store, must-revalidate" }; + contentRequest.Headers = new Dictionary { { "Pragma", "no-cache" }, { "Expires", "0" } }; + contentRequest.SetRedirectPermanent(url); return true; }