File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -385,18 +385,14 @@ export default async function Page() {
385385#### Page router
386386``` tsx
387387import { evaluateFlags , flagsClient , getDefinitions } from " @unleash/nextjs" ;
388- import { GetServerSideProps , NextPage } from " next" ;
388+ import type { GetServerSideProps , NextPage } from " next" ;
389389
390390type Data = {
391391 isEnabled: boolean ;
392392};
393393
394394export const getServerSideProps: GetServerSideProps <Data > = async () => {
395- const definitions = await getDefinitions ({
396- fetchOptions: {
397- next: { revalidate: 15 }, // Cache layer like Unleash Proxy!
398- },
399- });
395+ const definitions = await getDefinitions ();
400396 const context = {};
401397 const { toggles } = evaluateFlags (definitions , context );
402398 const flags = flagsClient (toggles );
Original file line number Diff line number Diff line change @@ -35,6 +35,10 @@ export const getServerSideProps: GetServerSideProps<Data> = async (ctx) => {
3535 "set-cookie" ,
3636 `${ UNLEASH_COOKIE_NAME } =${ sessionId } ; path=/;`
3737 ) ;
38+ ctx . res . setHeader (
39+ 'Cache-Control' , // In Pages Router you can cache entrie response, but not Unlaesh request only
40+ 'public, s-maxage=10, stale-while-revalidate=59'
41+ )
3842
3943 const definitions = await getDefinitions ( ) ;
4044 const { toggles } = evaluateFlags ( definitions , {
You can’t perform that action at this time.
0 commit comments