From cda77fdc2aa2c13fe4bcdb3156d9cfa3858aa9ed Mon Sep 17 00:00:00 2001 From: Visnu Pitiyanuvath Date: Thu, 18 Aug 2022 21:31:40 -0700 Subject: [PATCH] Bust both cache keys --- packages/next/shared/lib/router/router.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/next/shared/lib/router/router.ts b/packages/next/shared/lib/router/router.ts index 9ffc9ff87ea2..50e5b87d4f16 100644 --- a/packages/next/shared/lib/router/router.ts +++ b/packages/next/shared/lib/router/router.ts @@ -2015,7 +2015,6 @@ export default class Router implements BaseRouter { : await fetchNextData({ dataHref: this.pageLoader.getDataHref({ href: formatWithValidation({ pathname, query }), - skipInterpolation: true, asPath: resolvedAs, locale, }), @@ -2053,11 +2052,21 @@ export default class Router implements BaseRouter { // middleware can skip cache per request with // x-middleware-cache: no-cache as well if (routeInfo.__N_SSP && fetchNextDataParams.dataHref) { - const cacheKey = new URL( - fetchNextDataParams.dataHref, - window.location.href - ).href - delete this.sdc[cacheKey] + // The data cache can exist under two similar keys: one with + // interpolation and one without + delete this.sdc[ + new URL(fetchNextDataParams.dataHref, window.location.href).href + ] + delete this.sdc[ + new URL( + this.pageLoader.getDataHref({ + href: formatWithValidation({ pathname, query }), + asPath: resolvedAs, + locale, + }), + window.location.href + ).href + ] } // we kick off a HEAD request in the background