mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Closes: https://linear.app/vercel/issue/DOC-4686/clean-up-routing-section Redirects: https://github.com/vercel/front/pull/47151 --------- Co-authored-by: Joseph <[email protected]> Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
22 lines
1.0 KiB
Plaintext
22 lines
1.0 KiB
Plaintext
---
|
|
title: expireTime
|
|
description: Customize stale-while-revalidate expire time for ISR enabled pages.
|
|
---
|
|
|
|
{/* The content of this doc is shared between the app and pages router. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}
|
|
|
|
You can specify a custom `stale-while-revalidate` expire time for CDNs to consume in the `Cache-Control` header for ISR enabled pages.
|
|
|
|
Open `next.config.js` and add the `expireTime` config:
|
|
|
|
```js filename="next.config.js"
|
|
module.exports = {
|
|
// one hour in seconds
|
|
expireTime: 3600,
|
|
}
|
|
```
|
|
|
|
Now when sending the `Cache-Control` header the expire time will be calculated depending on the specific revalidate period.
|
|
|
|
For example, if you have a revalidate of 15 minutes on a path and the expire time is one hour the generated `Cache-Control` header will be `s-maxage=900, stale-while-revalidate=2700` so that it can stay stale for 15 minutes less than the configured expire time.
|