mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
The `DYNAMIC_EXPIRE` and `DYNAMIC_STALE` constants read as if the value itself is a dynamic expire or stale time, but every comparison is `expire < DYNAMIC_EXPIRE` / `stale < DYNAMIC_STALE`, so the value is the exclusive upper bound of the dynamic range: it is the smallest value that is *not* dynamic, not a dynamic value. The names are backwards at the boundary, which is easy to misread. The two thresholds also gate different things. `expire` gates whether a cache entry is included in the static prerender: below the threshold it becomes a dynamic hole, though a short-`expire` value is still served during a runtime prefetch. `stale` gates whether an entry is included in a runtime prefetch or app shell. This renames them to name that consequence: `MIN_PRERENDERABLE_EXPIRE` and `MIN_PREFETCHABLE_STALE`. It reads correctly both at the comparison sites (`expire < MIN_PRERENDERABLE_EXPIRE` is "below the minimum prerenderable expire", i.e. dynamic) and at the one site that uses the value directly, where private caches force `expire: MIN_PRERENDERABLE_EXPIRE` precisely because it is the shortest expire that stays prerenderable (and so is retained without being reclassified as a short-expire dynamic hole). This is a pure rename with no behavior change. --- <sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
33 lines
737 B
JavaScript
33 lines
737 B
JavaScript
/**
|
|
* @type {import('next').NextConfig}
|
|
*/
|
|
const nextConfig = {
|
|
cacheHandlers: {
|
|
custom: require.resolve(
|
|
'next/dist/server/lib/cache-handlers/default.external'
|
|
),
|
|
'no-store': require.resolve('./no-store-handler.js'),
|
|
},
|
|
experimental: {
|
|
useCache: true,
|
|
},
|
|
cacheLife: {
|
|
frequent: {
|
|
// >= MIN_PREFETCHABLE_STALE (30s) so the cache is still eligible for the
|
|
// static shell. A shorter stale time would exclude it from static
|
|
// prerenders.
|
|
stale: 30,
|
|
revalidate: 100,
|
|
expire: 300,
|
|
},
|
|
expireNow: {
|
|
stale: 0,
|
|
expire: 0,
|
|
revalidate: 0,
|
|
},
|
|
},
|
|
cacheHandler: require.resolve('./incremental-cache-handler'),
|
|
}
|
|
|
|
module.exports = nextConfig
|