-
SummarygetServerSideProps on redirect page can't get cached data. I'm using a translator, so forgive me if it's awkward. Thanks. I have two pages that use
The problem is when Actually, I don't think I know exactly what's going on... Does anyone else have a similar situation or anticipated problems? For now, I'm using Additional informationnext 13.4.3 ExampleHere is the full code for the import { GetServerSideProps } from "next";
import { URL } from "@/lib/�constants";
export const getServerSideProps: GetServerSideProps = async () => {
return {
redirect: {
destination: URL.MARKETPLACE,
permanent: true,
},
};
};
const HomePage = () => {
return <></>;
};
export default HomePage; Here is a portion of the code for export const getServerSideProps: GetServerSideProps = async ({ req, res }) => {
res.setHeader(
"Cache-Control",
`public, s-maxage=${12 * 60 * 60}, stale-while-revalidate=${0.5 * 60 * 60}`
);
const data = await fetchData();
return {
props: {
data: JSON.parse(JSON.stringify(data)),
},
};
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Can i ask you a few question to understand the context better? i think it will be useful to know:
|
Beta Was this translation helpful? Give feedback.
-
Is the problem happening when you navigate to page A, from another page, for example C? Or is it happening when you load A directly? Or maybe not, just random? Are you using |
Beta Was this translation helpful? Give feedback.
Yeah,
next-pwa
, by default has something called stale-while-revalidate, https://developer.chrome.com/docs/workbox/modules/workbox-strategies/#stale-while-revalidate, which for GSSP, is a problem.You need to use https://developer.chrome.com/docs/workbox/modules/workbox-strategies/#network-first-network-falling-back-to-cache:
I have answered to this before: #42405 (comment)
If that helps, please report back and don't forget to mark as answered.
Reposting for visiblity: