f6e5a816e2
Closes https://github.com/vercel/next.js/issues/12019 with a better example of proper SSR caching.
21 lines
393 B
JavaScript
21 lines
393 B
JavaScript
export default function Index({ time }) {
|
|
return (
|
|
<main>
|
|
<h1>SSR Caching with Next.js</h1>
|
|
<time dateTime={time}>{time}</time>
|
|
</main>
|
|
)
|
|
}
|
|
|
|
export async function getServerSideProps({ req, res }) {
|
|
res.setHeader(
|
|
'Cache-Control',
|
|
'public, s-maxage=10, stale-while-revalidate=59'
|
|
)
|
|
|
|
return {
|
|
props: {
|
|
time: new Date().toISOString(),
|
|
},
|
|
}
|
|
}
|