cache pages

This commit is contained in:
m5r 2021-07-21 12:00:43 +08:00
parent 067d0d97c4
commit f55f1c5359
4 changed files with 32 additions and 7 deletions

View File

@ -27,10 +27,13 @@ const Calls: NextPage<Props> = (props) => {
};
export const getServerSideProps = withPageOnboardingRequired(
async (context, user) => {
return {
props: { userId: user.id, ddd: 23 as const },
};
async ({ res }) => {
res.setHeader(
"Cache-Control",
"private, s-maxage=15, stale-while-revalidate=59",
);
return { props: {} };
},
);

View File

@ -50,7 +50,8 @@ const Keypad: NextPage<Props> = () => {
<Digit digit="#" />
</Row>
<Row>
<div className="select-none col-start-2 h-12 w-12 flex justify-center items-center mx-auto bg-green-800 rounded-full">
<div
className="select-none col-start-2 h-12 w-12 flex justify-center items-center mx-auto bg-green-800 rounded-full">
<FontAwesomeIcon icon={faPhone} color="white" size="lg" />
</div>
<div className="select-none my-auto" onClick={pressBackspace}>
@ -117,6 +118,13 @@ const pressBackspaceAtom = atom(
},
);
export const getServerSideProps = withPageOnboardingRequired();
export const getServerSideProps = withPageOnboardingRequired(({ res }) => {
res.setHeader(
"Cache-Control",
"private, s-maxage=15, stale-while-revalidate=59",
);
return { props: {} };
});
export default Keypad;

View File

@ -49,6 +49,11 @@ type Recipient = string;
export const getServerSideProps = withPageOnboardingRequired(
async (context, user) => {
context.res.setHeader(
"Cache-Control",
"private, s-maxage=15, stale-while-revalidate=59",
);
const [customer, messages] = await Promise.all([
findCustomer(user.id),
findCustomerMessages(user.id),

View File

@ -49,6 +49,15 @@ const Settings: NextPage<Props> = (props) => {
);
};
export const getServerSideProps = withPageOnboardingRequired();
export const getServerSideProps = withPageOnboardingRequired(
async ({ res }) => {
res.setHeader(
"Cache-Control",
"private, s-maxage=15, stale-while-revalidate=59",
);
return { props: {} };
},
);
export default Settings;