Skip to content

Commit

Permalink
Bust both cache keys
Browse files Browse the repository at this point in the history
  • Loading branch information
visnup committed Aug 19, 2022
1 parent 1673534 commit cda77fd
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions packages/next/shared/lib/router/router.ts
Expand Up @@ -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,
}),
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cda77fd

Please sign in to comment.