You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Propagate expire time to cache-control header and prerender manifest
For the `stale-while-revalidate` value in the `Cache-Control` response
header, Next.js currently uses the configured
[`expireTime`](https://nextjs.org/docs/app/api-reference/config/next-config-js/expireTime),
which defaults to one year.
With the introduction of `"use cache"` and granular [cache
lifetimes](https://nextjs.org/docs/app/api-reference/functions/cacheLife),
users can now set expire times per route — based on the minimum expire
time of all cached functions used by that route.
This PR updates the `stale-while-revalidate` value to reflect the
route's cache lifetime, using the difference between the minimum expire
time and the minimum revalidate time. If no explicit expire time is
defined in cache profiles, the globally configured `expireTime` is used.
Additionally, the collected expire time is added to the prerender
manifest as `initialExpireSeconds`, analogous to
`initialRevalidateSeconds`.
Copy file name to clipboardExpand all lines: packages/next/errors.json
+6-1
Original file line number
Diff line number
Diff line change
@@ -644,5 +644,10 @@
644
644
"643": "Invalid \"devIndicator.position\" provided, expected one of %s, received %s",
645
645
"644": "@rspack/core is not available. Please make sure the appropriate Next.js plugin is installed.",
646
646
"645": "@rspack/plugin-react-refresh is not available. Please make sure the appropriate Next.js plugin is installed.",
647
-
"646": "No span found for compilation"
647
+
"646": "No span found for compilation",
648
+
"647": "If providing both the stale and expire options, the expire option must be greater than the stale option. The expire option indicates how many seconds from the start until it can no longer be used.",
649
+
"648": "If providing both the revalidate and expire options, the expire option must be greater than the revalidate option. The expire option indicates how many seconds from the start until it can no longer be used.",
650
+
"649": "revalidate must be a number for image-cache",
651
+
"650": "Pass `Infinity` instead of `false` if you want to cache on the server forever without checking with the origin.",
652
+
"651": "SSG should not return an image cache value"
0 commit comments