diff --git a/pages/blog/diary/[did].tsx b/pages/blog/diary/[did].tsx index 4190dcd..62d208c 100644 --- a/pages/blog/diary/[did].tsx +++ b/pages/blog/diary/[did].tsx @@ -21,6 +21,8 @@ export const getServerSideProps: GetServerSideProps = async (context) => { const contentHtml = await generateContent(contentEntry) as string; const contentPrepared = prepareDOM(contentHtml); + context.res.setHeader("Cache-Control", "public, s-maxage=3600, stale-while-revalidate=600"); + return { props: { content: { diff --git a/pages/blog/diary/[did]/[page].tsx b/pages/blog/diary/[did]/[page].tsx index c802448..b2b34e6 100644 --- a/pages/blog/diary/[did]/[page].tsx +++ b/pages/blog/diary/[did]/[page].tsx @@ -21,6 +21,8 @@ export const getServerSideProps: GetServerSideProps = async (context) => { const contentHtml = await generateContent(contentEntry, Number.parseInt(page)) as string; const contentPrepared = prepareDOM(contentHtml); + context.res.setHeader("Cache-Control", "public, s-maxage=3600, stale-while-revalidate=600"); + return { props: { content: { diff --git a/pages/blog/project/[pid].tsx b/pages/blog/project/[pid].tsx index ec142b2..a733cb8 100644 --- a/pages/blog/project/[pid].tsx +++ b/pages/blog/project/[pid].tsx @@ -22,6 +22,8 @@ export const getServerSideProps: GetServerSideProps = async (context) => { const contentHtml = await generateContent(contentEntry) as string; const contentPrepared = prepareDOM(contentHtml); + context.res.setHeader("Cache-Control", "public, s-maxage=3600, stale-while-revalidate=600"); + return { props: { content: { diff --git a/pages/index.tsx b/pages/index.tsx index 99cd277..bd80556 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,4 +1,4 @@ -import type { NextPage } from "next"; +import type { GetServerSideProps, NextPage } from "next"; import Link from "next/link"; import gen from "random-seed"; import Layout from "../components/Blog/Layout"; @@ -57,8 +57,10 @@ const Blog: NextPage<{ content: ContentList }> = ({content}) => { }; -export async function getServerSideProps() { +export const getServerSideProps: GetServerSideProps = async ({ res }) => { + res.setHeader("Cache-Control", "public, s-maxage=3600, stale-while-revalidate=600"); + return { props: { content: await getContentList() } }; -} +}; export default Blog; \ No newline at end of file