From 5759a2c2dab08b3982c3929c61e1e5815f662805 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 | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/next/shared/lib/router/router.ts b/packages/next/shared/lib/router/router.ts index 9ffc9ff87ea2..17cb9d7c2778 100644 --- a/packages/next/shared/lib/router/router.ts +++ b/packages/next/shared/lib/router/router.ts @@ -1918,7 +1918,6 @@ export default class Router implements BaseRouter { const fetchNextDataParams: FetchNextDataParams = { dataHref: this.pageLoader.getDataHref({ href: formatWithValidation({ pathname, query }), - skipInterpolation: true, asPath: resolvedAs, locale, }), @@ -2015,7 +2014,6 @@ export default class Router implements BaseRouter { : await fetchNextData({ dataHref: this.pageLoader.getDataHref({ href: formatWithValidation({ pathname, query }), - skipInterpolation: true, asPath: resolvedAs, locale, }), @@ -2053,11 +2051,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