MCPcopy
hub / github.com/vercel/next.js / getCacheControlHeader

Function getCacheControlHeader

packages/next/src/server/lib/cache-control.ts:17–35  ·  view source on GitHub ↗
({
  revalidate,
  expire,
}: CacheControl)

Source from the content-addressed store, hash-verified

15}
16
17export function getCacheControlHeader({
18 revalidate,
19 expire,
20}: CacheControl): string {
21 const swrHeader =
22 typeof revalidate === 'number' &&
23 expire !== undefined &&
24 revalidate < expire
25 ? `, stale-while-revalidate=${expire - revalidate}`
26 : ''
27
28 if (revalidate === 0) {
29 return 'private, no-cache, no-store, max-age=0, must-revalidate'
30 } else if (typeof revalidate === 'number') {
31 return `s-maxage=${revalidate}${swrHeader}`
32 }
33
34 return `s-maxage=${CACHE_ONE_YEAR_SECONDS}${swrHeader}`
35}

Callers 3

renderToHTMLImplFunction · 0.90
sendRenderResultFunction · 0.90
handleResponseFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…