在Next.js version 12
个应用程序使用getServerSideProps
,我有一个问题,从我的生产CMS到我的生产博客上的内容.
当我从CMS向本地应用程序添加条目时,它会在我的本地应用程序上更新.
除非我在生产时重新部署我的站点,否则它不会更新我的生产站点.
我正在寻找一种解决办法,并考虑这些选项:
- 我应该试着像doctor 一样做到
cache dynamic responses
吗?
res.setHeader(
'Cache-Control',
'public, s-maxage=10, stale-while-revalidate=59'
)
- 我应该换到
getstaticprops
,在那里我可以使用revalidate
房产吗? - 我应该使用第三方库来解决这个问题吗?
- this article会和我的问题有关吗?
以下是通过getServerSideProps
读取的代码片段:
async function getAllArticles() {
const { data } = await apolloClient.query({
query: gql`
query getAllArticles {
name
}
`,
});
return data;
}
export async function getServerSideProps() {
const allArticles = await getAllArticles();
return {
props: {
allArticles
},
};
}
const Articles: NextPage = ({allArticles}) => {
... // allArticles don't update until redeploy
如有任何帮助,将不胜感激