rsnext/examples/ssr-caching/pages/index.js
Lee Robinson f6e5a816e2
[examples] Fix ssr-caching example. (#26540)
Closes https://github.com/vercel/next.js/issues/12019 with a better example of proper SSR caching.
2021-06-23 18:27:19 +00:00

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(),
},
}
}