Skip to content

Commit

Permalink
Avoid SWR cache-control headers in prerender prefetch tests
Browse files Browse the repository at this point in the history
  • Loading branch information
unstubbable committed Feb 20, 2025
1 parent 1d9f40a commit 2c229c7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,9 @@ export const defaultConfig: NextConfig = {
keepAlive: true,
},
logging: {},
expireTime: 31536000, // one year
expireTime: process.env.NEXT_PRIVATE_CDN_CONSUMED_SWR_CACHE_CONTROL
? undefined
: 31536000, // one year
staticPageGenerationTimeout: 60,
output: !!process.env.NEXT_PRIVATE_STANDALONE ? 'standalone' : undefined,
modularizeImports: undefined,
Expand Down
14 changes: 14 additions & 0 deletions test/production/prerender-prefetch/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,13 @@ describe('Prerender prefetch', () => {
pages: new FileRef(join(__dirname, 'app/pages')),
},
dependencies: {},
env: {
// Simulate that a CDN has consumed the SWR cache-control header,
// otherwise the browser will cache responses and which messes with
// the expectations in this test.
// See https://github.com/vercel/next.js/pull/70674 for context.
NEXT_PRIVATE_CDN_CONSUMED_SWR_CACHE_CONTROL: '1',
},
})
})
afterAll(() => next.destroy())
Expand All @@ -319,6 +326,13 @@ describe('Prerender prefetch', () => {
},
},
dependencies: {},
env: {
// Simulate that a CDN has consumed the SWR cache-control header,
// otherwise the browser will cache responses and which messes with
// the expectations in this test.
// See https://github.com/vercel/next.js/pull/70674 for context.
NEXT_PRIVATE_CDN_CONSUMED_SWR_CACHE_CONTROL: '1',
},
})
})
afterAll(() => next.destroy())
Expand Down

0 comments on commit 2c229c7

Please sign in to comment.