diff --git a/packages/next/src/server/config-shared.ts b/packages/next/src/server/config-shared.ts index 258c0394e00324..db39319f12781c 100644 --- a/packages/next/src/server/config-shared.ts +++ b/packages/next/src/server/config-shared.ts @@ -1129,7 +1129,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, diff --git a/test/production/prerender-prefetch/index.test.ts b/test/production/prerender-prefetch/index.test.ts index 4317ce74e8d0a0..0518d9b98b46b3 100644 --- a/test/production/prerender-prefetch/index.test.ts +++ b/test/production/prerender-prefetch/index.test.ts @@ -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()) @@ -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())