Skip to content

Commit

Permalink
Add x-middleware-cache header to allow opt-out from preflight cache
Browse files Browse the repository at this point in the history
  • Loading branch information
javivelasco committed Dec 23, 2021
1 parent a5bc3f3 commit 34bbb3c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/next/shared/lib/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ interface NextHistoryState {
}

interface PreflightData {
cache?: string | null
redirect?: string | null
refresh?: boolean
rewrite?: string | null
Expand Down Expand Up @@ -1950,14 +1951,15 @@ export default class Router implements BaseRouter {
}

return {
cache: res.headers.get('x-middleware-cache'),
redirect: res.headers.get('Location'),
refresh: res.headers.has('x-middleware-refresh'),
rewrite: res.headers.get('x-middleware-rewrite'),
ssr: !!res.headers.get('x-middleware-ssr'),
}
})
.then((data) => {
if (shouldCache) {
if (shouldCache && data.cache !== 'no-cache') {
this.sde[cacheKey] = data
}

Expand Down

0 comments on commit 34bbb3c

Please sign in to comment.