2021-06-23 20:27:19 +02:00
|
|
|
export default function Index({ time }) {
|
2020-05-18 23:44:18 +02:00
|
|
|
return (
|
2021-06-23 20:27:19 +02:00
|
|
|
<main>
|
|
|
|
<h1>SSR Caching with Next.js</h1>
|
|
|
|
<time dateTime={time}>{time}</time>
|
|
|
|
</main>
|
2020-05-18 23:44:18 +02:00
|
|
|
)
|
|
|
|
}
|
2021-06-23 20:27:19 +02:00
|
|
|
|
|
|
|
export async function getServerSideProps({ req, res }) {
|
|
|
|
res.setHeader(
|
|
|
|
'Cache-Control',
|
|
|
|
'public, s-maxage=10, stale-while-revalidate=59'
|
|
|
|
)
|
|
|
|
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
time: new Date().toISOString(),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|