Unverified Commit 2aa12031 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Configure the Default Revalidate (#8880)

* Configure the Default Revalidate
The default revalidate behavior should be configured by Next.js. Otherwise, the behavior might drift or change in non-semver compliant ways between Next.js and the builder (or other 3rd party setups).

* Add additional comment
parent 01e54718
...@@ -415,6 +415,14 @@ export async function renderToHTML( ...@@ -415,6 +415,14 @@ export async function renderToHTML(
`\nTo only run getStaticProps at build-time and not revalidate at runtime, you can set \`revalidate\` to \`false\`!` `\nTo only run getStaticProps at build-time and not revalidate at runtime, you can set \`revalidate\` to \`false\`!`
) )
} }
} else if (data.revalidate === false) {
// `false` is an allowed behavior. We'll catch `revalidate: true` and
// fall into our default behavior.
} else {
// By default, we revalidate after 1 second. This value is optimal for
// the most up-to-date page possible, but without a 1-to-1
// request-refresh ratio.
data.revalidate = 1
} }
props.pageProps = data.props props.pageProps = data.props
......
import Link from 'next/link'
// eslint-disable-next-line camelcase
export async function unstable_getStaticProps () {
return {
props: {
world: 'world',
time: new Date().getTime()
}
}
}
export default ({ world, time }) => (
<>
<p>hello {world}</p>
<span>time: {time}</span>
<Link href='/'>
<a id='home'>to home</a>
</Link>
<br />
<Link href='/something'>
<a id='something'>to something</a>
</Link>
</>
)
...@@ -172,6 +172,9 @@ const runTests = (dev = false) => { ...@@ -172,6 +172,9 @@ const runTests = (dev = false) => {
'/another': { '/another': {
initialRevalidateSeconds: 0 initialRevalidateSeconds: 0
}, },
'/default-revalidate': {
initialRevalidateSeconds: 1
},
'/something': { '/something': {
initialRevalidateSeconds: false initialRevalidateSeconds: false
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment