diff --git a/tests/e2e/cli-before-regional-blobs-support.test.ts b/tests/e2e/cli-before-regional-blobs-support.test.ts index a19a490053..0e3b310d4e 100644 --- a/tests/e2e/cli-before-regional-blobs-support.test.ts +++ b/tests/e2e/cli-before-regional-blobs-support.test.ts @@ -19,7 +19,7 @@ test('should serve 404 page when requesting non existing page (no matching route expect(await page.textContent('h1')).toBe('404') expect(headers['netlify-cdn-cache-control']).toBe( - 'no-cache, no-store, max-age=0, must-revalidate', + 'no-cache, no-store, max-age=0, must-revalidate, durable', ) expect(headers['cache-control']).toBe('no-cache,no-store,max-age=0,must-revalidate') }) diff --git a/tests/e2e/durable-cache.test.ts b/tests/e2e/durable-cache.test.ts deleted file mode 100644 index 269203ba89..0000000000 --- a/tests/e2e/durable-cache.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { expect } from '@playwright/test' -import { test } from '../utils/playwright-helpers.js' - -// This fixture is deployed to a separate site with the feature flag enabled -test('sets cache-control `durable` directive when feature flag is enabled', async ({ - page, - durableCache, -}) => { - const response = await page.goto(durableCache.url) - const headers = response?.headers() || {} - - const h1 = page.locator('h1') - await expect(h1).toHaveText('Home') - - expect(headers['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000, durable', - ) - expect(headers['cache-control']).toBe('public,max-age=0,must-revalidate') -}) diff --git a/tests/e2e/on-demand-app.test.ts b/tests/e2e/on-demand-app.test.ts index 85b1fb69dd..27870efe47 100644 --- a/tests/e2e/on-demand-app.test.ts +++ b/tests/e2e/on-demand-app.test.ts @@ -76,7 +76,7 @@ test.describe('app router on-demand revalidation', () => { expect(response1?.status()).toBe(200) expect(headers1['x-nextjs-cache']).toBeUndefined() expect(headers1['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) const date1 = await page.textContent('[data-testid="date-now"]') @@ -104,7 +104,7 @@ test.describe('app router on-demand revalidation', () => { expect(headers2['cache-status']).toMatch(/"Next.js"; hit/m) } expect(headers2['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) // the page is cached @@ -134,7 +134,7 @@ test.describe('app router on-demand revalidation', () => { expect(response3?.status()).toBe(200) expect(headers3?.['x-nextjs-cache']).toBeUndefined() expect(headers3['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) // the page has now an updated date @@ -161,7 +161,7 @@ test.describe('app router on-demand revalidation', () => { expect(headers4['cache-status']).toMatch(/"Next.js"; hit/m) } expect(headers4['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) // the page is cached diff --git a/tests/e2e/page-router.test.ts b/tests/e2e/page-router.test.ts index a92f0cbcbb..895a2025fb 100644 --- a/tests/e2e/page-router.test.ts +++ b/tests/e2e/page-router.test.ts @@ -111,7 +111,7 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => { expect(headers1['x-nextjs-cache']).toBeUndefined() expect(headers1['netlify-cache-tag']).toBe(`_n_t_${pagePath}`) expect(headers1['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) const date1 = await page.textContent('[data-testid="date-now"]') @@ -139,7 +139,7 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => { expect(headers1Json['x-nextjs-cache']).toBeUndefined() expect(headers1Json['netlify-cache-tag']).toBe(`_n_t_${pagePath}`) expect(headers1Json['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) const data1 = (await response1Json?.json()) || {} expect(data1?.pageProps?.time).toBe(date1) @@ -164,7 +164,7 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => { expect(headers2['cache-status']).toMatch(/"Next.js"; hit/m) } expect(headers2['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) // the page is cached @@ -195,7 +195,7 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => { expect(headers2Json['cache-status']).toMatch(/"Next.js"; hit/m) } expect(headers2Json['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) const data2 = (await response2Json?.json()) || {} @@ -250,7 +250,7 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => { expect(response3Json?.status()).toBe(200) expect(headers3Json['x-nextjs-cache']).toBeUndefined() expect(headers3Json['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) const data3 = (await response3Json?.json()) || {} @@ -341,7 +341,7 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => { expect(await page.textContent('h1')).toBe('404') expect(headers['netlify-cdn-cache-control']).toBe( - 'no-cache, no-store, max-age=0, must-revalidate', + 'no-cache, no-store, max-age=0, must-revalidate, durable', ) expect(headers['cache-control']).toBe('no-cache,no-store,max-age=0,must-revalidate') }) @@ -357,7 +357,7 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => { expect(await page.textContent('h1')).toBe('404') expect(headers['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) expect(headers['cache-control']).toBe('public,max-age=0,must-revalidate') }) @@ -401,7 +401,7 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => { const response = await page.goto(new URL('static/fully-static', pageRouter.url).href) const headers = response?.headers() || {} - expect(headers['netlify-cdn-cache-control']).toBe('max-age=31536000') + expect(headers['netlify-cdn-cache-control']).toBe('max-age=31536000, durable') expect(headers['cache-control']).toBe('public,max-age=0,must-revalidate') }) @@ -487,7 +487,7 @@ test.describe('Page Router with basePath and i18n', () => { expect(headers1ImplicitLocale['x-nextjs-cache']).toBeUndefined() expect(headers1ImplicitLocale['netlify-cache-tag']).toBe(`_n_t_/en${pagePath}`) expect(headers1ImplicitLocale['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) const date1ImplicitLocale = await page.textContent('[data-testid="date-now"]') @@ -513,7 +513,7 @@ test.describe('Page Router with basePath and i18n', () => { expect(headers1ExplicitLocale['x-nextjs-cache']).toBeUndefined() expect(headers1ExplicitLocale['netlify-cache-tag']).toBe(`_n_t_/en${pagePath}`) expect(headers1ExplicitLocale['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) const date1ExplicitLocale = await page.textContent('[data-testid="date-now"]') @@ -545,7 +545,7 @@ test.describe('Page Router with basePath and i18n', () => { expect(headers1Json['x-nextjs-cache']).toBeUndefined() expect(headers1Json['netlify-cache-tag']).toBe(`_n_t_/en${pagePath}`) expect(headers1Json['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) const data1 = (await response1Json?.json()) || {} expect(data1?.pageProps?.time).toBe(date1ImplicitLocale) @@ -573,7 +573,7 @@ test.describe('Page Router with basePath and i18n', () => { expect(headers2ImplicitLocale['cache-status']).toMatch(/"Next.js"; hit/m) } expect(headers2ImplicitLocale['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) // the page is cached @@ -603,7 +603,7 @@ test.describe('Page Router with basePath and i18n', () => { expect(headers2ExplicitLocale['cache-status']).toMatch(/"Next.js"; hit/m) } expect(headers2ExplicitLocale['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) // the page is cached @@ -634,7 +634,7 @@ test.describe('Page Router with basePath and i18n', () => { expect(headers2Json['cache-status']).toMatch(/"Next.js"; hit/m) } expect(headers2Json['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) const data2 = (await response2Json?.json()) || {} @@ -728,7 +728,7 @@ test.describe('Page Router with basePath and i18n', () => { expect(headers3Json['cache-status']).toMatch(/"Next.js"; hit/m) } expect(headers3Json['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) const data3 = (await response3Json?.json()) || {} @@ -817,7 +817,7 @@ test.describe('Page Router with basePath and i18n', () => { expect(response4Json?.status()).toBe(200) expect(headers4Json['x-nextjs-cache']).toBeUndefined() expect(headers4Json['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) const data4 = (await response4Json?.json()) || {} @@ -863,7 +863,7 @@ test.describe('Page Router with basePath and i18n', () => { expect(headers1['x-nextjs-cache']).toBeUndefined() expect(headers1['netlify-cache-tag']).toBe(`_n_t_/de${pagePath}`) expect(headers1['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) const date1 = await page.textContent('[data-testid="date-now"]') @@ -892,7 +892,7 @@ test.describe('Page Router with basePath and i18n', () => { expect(headers1Json['x-nextjs-cache']).toBeUndefined() expect(headers1Json['netlify-cache-tag']).toBe(`_n_t_/de${pagePath}`) expect(headers1Json['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) const data1 = (await response1Json?.json()) || {} expect(data1?.pageProps?.time).toBe(date1) @@ -920,7 +920,7 @@ test.describe('Page Router with basePath and i18n', () => { expect(headers2['cache-status']).toMatch(/"Next.js"; hit/m) } expect(headers2['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) // the page is cached @@ -952,7 +952,7 @@ test.describe('Page Router with basePath and i18n', () => { expect(headers2Json['cache-status']).toMatch(/"Next.js"; hit/m) } expect(headers2Json['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) const data2 = (await response2Json?.json()) || {} @@ -1019,7 +1019,7 @@ test.describe('Page Router with basePath and i18n', () => { expect(headers3Json['cache-status']).toMatch(/"Next.js"; hit/m) } expect(headers3Json['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) const data3 = (await response3Json?.json()) || {} @@ -1040,7 +1040,7 @@ test.describe('Page Router with basePath and i18n', () => { expect(await page.textContent('h1')).toBe('404') expect(headers['netlify-cdn-cache-control']).toBe( - 'no-cache, no-store, max-age=0, must-revalidate', + 'no-cache, no-store, max-age=0, must-revalidate, durable', ) expect(headers['cache-control']).toBe('no-cache,no-store,max-age=0,must-revalidate') }) @@ -1056,7 +1056,7 @@ test.describe('Page Router with basePath and i18n', () => { expect(await page.textContent('h1')).toBe('404') expect(headers['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) expect(headers['cache-control']).toBe('public,max-age=0,must-revalidate') }) diff --git a/tests/e2e/simple-app.test.ts b/tests/e2e/simple-app.test.ts index a9f440c331..7fc38bb5a7 100644 --- a/tests/e2e/simple-app.test.ts +++ b/tests/e2e/simple-app.test.ts @@ -12,9 +12,12 @@ test('Renders the Home page correctly', async ({ page, simple }) => { await expect(page).toHaveTitle('Simple Next App') - expect(headers['cache-status']).toBe( - '"Next.js"; hit\n"Netlify Durable"; fwd=miss\n"Netlify Edge"; fwd=miss', - ) + expect(headers['cache-status']).toMatch(/^"Next.js"; hit$/m) + expect(headers['cache-status']).toMatch(/^"Netlify Edge"; fwd=miss$/m) + // "Netlify Durable" assertion is skipped because we are asserting index page and there are possible that something else is making similar request to it + // and as a result we can see many possible statuses for it: `fwd=miss`, `fwd=miss; stored`, `hit; ttl=` so there is no point in asserting on that + // "Netlify Edge" status suffers from similar issue, but is less likely to manifest (only if those requests would be handled by same CDN node) and retries + // usually allow to pass the test const h1 = page.locator('h1') await expect(h1).toHaveText('Home') @@ -222,7 +225,7 @@ test('requesting a non existing page route that needs to be fetched from the blo expect(headers['netlify-cdn-cache-control']).toBe( (shouldHavePrivateDirective ? 'private, ' : '') + - 'no-cache, no-store, max-age=0, must-revalidate', + 'no-cache, no-store, max-age=0, must-revalidate, durable', ) expect(headers['cache-control']).toBe( (shouldHavePrivateDirective ? 'private,' : '') + 'no-cache,no-store,max-age=0,must-revalidate', @@ -240,7 +243,7 @@ test('requesting a non existing page route that needs to be fetched from the blo expect(await page.textContent('h1')).toBe('404 Not Found') expect(headers['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) expect(headers['cache-control']).toBe('public,max-age=0,must-revalidate') }) diff --git a/tests/e2e/turborepo.test.ts b/tests/e2e/turborepo.test.ts index 77d8426f9a..9afecccd9d 100644 --- a/tests/e2e/turborepo.test.ts +++ b/tests/e2e/turborepo.test.ts @@ -35,7 +35,7 @@ test.describe('[PNPM] Package manager', () => { expect(response1?.status()).toBe(200) expect(headers1['x-nextjs-cache']).toBeUndefined() expect(headers1['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) const date1 = await page.textContent('[data-testid="date-now"]') @@ -65,7 +65,7 @@ test.describe('[PNPM] Package manager', () => { expect(headers2['cache-status']).toMatch(/"Next.js"; hit/m) } expect(headers2['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) // the page is cached @@ -139,7 +139,7 @@ test.describe('[NPM] Package manager', () => { expect(response1?.status()).toBe(200) expect(headers1['x-nextjs-cache']).toBeUndefined() expect(headers1['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) const date1 = await page.textContent('[data-testid="date-now"]') @@ -169,7 +169,7 @@ test.describe('[NPM] Package manager', () => { expect(headers2['cache-status']).toMatch(/"Next.js"; hit/m) } expect(headers2['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) // the page is cached diff --git a/tests/integration/cache-handler.test.ts b/tests/integration/cache-handler.test.ts index afc308de24..6d37909b2a 100644 --- a/tests/integration/cache-handler.test.ts +++ b/tests/integration/cache-handler.test.ts @@ -88,7 +88,7 @@ describe('page router', () => { ).toEqual( expect.objectContaining({ 'cache-status': '"Next.js"; hit', - 'netlify-cdn-cache-control': 's-maxage=5, stale-while-revalidate=31536000', + 'netlify-cdn-cache-control': 's-maxage=5, stale-while-revalidate=31536000, durable', }), ) expect( @@ -239,7 +239,7 @@ describe('app router', () => { // It will be hit instead of stale expect.objectContaining({ 'cache-status': '"Next.js"; hit', - 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000', + 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000, durable', }), ) expect( diff --git a/tests/integration/fetch-handler.test.ts b/tests/integration/fetch-handler.test.ts index 1cdd079849..8d8905968a 100644 --- a/tests/integration/fetch-handler.test.ts +++ b/tests/integration/fetch-handler.test.ts @@ -229,7 +229,7 @@ test('if the fetch call is cached correctly (cached page res ).toEqual( expect.objectContaining({ 'cache-status': '"Next.js"; hit', - 'netlify-cdn-cache-control': 's-maxage=5, stale-while-revalidate=31536000', + 'netlify-cdn-cache-control': 's-maxage=5, stale-while-revalidate=31536000, durable', }), ) @@ -295,7 +295,7 @@ test('if the fetch call is cached correctly (cached page res ).toEqual( expect.objectContaining({ 'cache-status': '"Next.js"; hit', - 'netlify-cdn-cache-control': 's-maxage=5, stale-while-revalidate=31536000', + 'netlify-cdn-cache-control': 's-maxage=5, stale-while-revalidate=31536000, durable', }), ) }) diff --git a/tests/integration/page-router.test.ts b/tests/integration/page-router.test.ts index 8561901570..c246a47748 100644 --- a/tests/integration/page-router.test.ts +++ b/tests/integration/page-router.test.ts @@ -121,7 +121,7 @@ test.skipIf(platform === 'win32')( url: '/static/fully-static', }) - expect(response.headers?.['netlify-cdn-cache-control']).toBe('max-age=31536000') + expect(response.headers?.['netlify-cdn-cache-control']).toBe('max-age=31536000, durable') expect(response.headers?.['cache-control']).toBe('public, max-age=0, must-revalidate') }, ) diff --git a/tests/integration/revalidate-path.test.ts b/tests/integration/revalidate-path.test.ts index 0e6f8a2a0d..342872e1e3 100644 --- a/tests/integration/revalidate-path.test.ts +++ b/tests/integration/revalidate-path.test.ts @@ -67,7 +67,7 @@ test('should revalidate a route by path', async (ctx) => { expect(post1.headers, 'a cache hit on the first invocation of a prerendered page').toEqual( expect.objectContaining({ 'cache-status': expect.stringMatching(/"Next.js"; hit/), - 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000', + 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000, durable', }), ) @@ -82,7 +82,7 @@ test('should revalidate a route by path', async (ctx) => { expect(post1Route2.headers, 'a cache hit on the first invocation of a prerendered page').toEqual( expect.objectContaining({ 'cache-status': expect.stringMatching(/"Next.js"; hit/), - 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000', + 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000, durable', }), ) @@ -110,7 +110,7 @@ test('should revalidate a route by path', async (ctx) => { expect(post2.headers, 'a cache miss on the on demand revalidated path /1').toEqual( expect.objectContaining({ 'cache-status': '"Next.js"; fwd=miss', - 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000', + 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000, durable', }), ) expect(post2Date).not.toBe(post1Date) @@ -127,7 +127,7 @@ test('should revalidate a route by path', async (ctx) => { expect(post2Route2.headers, 'a cache miss on the on demand revalidated path /2').toEqual( expect.objectContaining({ 'cache-status': '"Next.js"; fwd=miss', - 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000', + 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000, durable', }), ) diff --git a/tests/integration/revalidate-tags.test.ts b/tests/integration/revalidate-tags.test.ts index 714a6eae0c..9b48c23956 100644 --- a/tests/integration/revalidate-tags.test.ts +++ b/tests/integration/revalidate-tags.test.ts @@ -67,7 +67,7 @@ test('should revalidate a route by tag', async (ctx) => { expect(post1.headers, 'a cache hit on the first invocation of a prerendered page').toEqual( expect.objectContaining({ 'cache-status': expect.stringMatching(/"Next.js"; hit/), - 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000', + 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000, durable', }), ) @@ -94,7 +94,7 @@ test('should revalidate a route by tag', async (ctx) => { expect(post2.headers, 'a cache miss on the on demand revalidated page').toEqual( expect.objectContaining({ 'cache-status': '"Next.js"; fwd=miss', - 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000', + 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000, durable', }), ) expect(post2Date).not.toBe(post1Date) @@ -117,7 +117,7 @@ test('should revalidate a route by tag', async (ctx) => { expect(post3.headers, 'a cache hit on the revalidated and regenerated page').toEqual( expect.objectContaining({ 'cache-status': expect.stringMatching(/"Next.js"; hit/), - 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000', + 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000, durable', }), ) expect(post3Date).toBe(post2Date) @@ -146,7 +146,7 @@ test('should revalidate a route by tag', async (ctx) => { expect(post4.headers, 'a cache miss on the on demand revalidated page').toEqual( expect.objectContaining({ 'cache-status': '"Next.js"; fwd=miss', - 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000', + 'netlify-cdn-cache-control': 's-maxage=31536000, stale-while-revalidate=31536000, durable', }), ) expect(post4Date).not.toBe(post3Date) diff --git a/tests/integration/simple-app.test.ts b/tests/integration/simple-app.test.ts index 58ccf8be6d..8d5dfcfdb8 100644 --- a/tests/integration/simple-app.test.ts +++ b/tests/integration/simple-app.test.ts @@ -153,7 +153,9 @@ test('stale-while-revalidate headers should be normalized to await createFixture('simple', ctx) await runPlugin(ctx) const index = await invokeFunction(ctx, { url: '/' }) - expect(index.headers?.['netlify-cdn-cache-control']).toContain('stale-while-revalidate=31536000') + expect(index.headers?.['netlify-cdn-cache-control']).toContain( + 'stale-while-revalidate=31536000, durable', + ) }) test('handlers receive correct site domain', async (ctx) => { @@ -185,7 +187,7 @@ test('cacheable route handler is cached on cdn (revalidate=f const permanentlyCachedResponse = await invokeFunction(ctx, { url: '/api/cached-permanent' }) expect(permanentlyCachedResponse.headers['netlify-cdn-cache-control']).toBe( - 's-maxage=31536000, stale-while-revalidate=31536000', + 's-maxage=31536000, stale-while-revalidate=31536000, durable', ) }) @@ -204,7 +206,7 @@ test('cacheable route handler is cached on cdn (revalidate=1 const secondTimeCachedResponse = await invokeFunction(ctx, { url: '/api/cached-revalidate' }) expect(secondTimeCachedResponse.headers['netlify-cdn-cache-control']).toBe( - 's-maxage=15, stale-while-revalidate=31536000', + 's-maxage=15, stale-while-revalidate=31536000, durable', ) }) diff --git a/tests/integration/static.test.ts b/tests/integration/static.test.ts index 14ded6c943..b4f6d6ade4 100644 --- a/tests/integration/static.test.ts +++ b/tests/integration/static.test.ts @@ -52,7 +52,7 @@ test('requesting a non existing page route that needs to be expect(load(call1.body)('h1').text()).toBe('404') expect(call1.headers, 'a cache hit on the first invocation of a prerendered page').toEqual( expect.objectContaining({ - 'netlify-cdn-cache-control': 'no-cache, no-store, max-age=0, must-revalidate', + 'netlify-cdn-cache-control': 'no-cache, no-store, max-age=0, must-revalidate, durable', }), ) }) diff --git a/tests/utils/create-e2e-fixture.ts b/tests/utils/create-e2e-fixture.ts index f1724c8d6a..9718e28711 100644 --- a/tests/utils/create-e2e-fixture.ts +++ b/tests/utils/create-e2e-fixture.ts @@ -428,10 +428,4 @@ export const fixtureFactories = { publishDirectory: 'apps/site/.next', smoke: true, }), - durableCache: () => - createE2EFixture('simple', { - // https://app.netlify.com/sites/next-runtime-testing-durable-cache - // This site has all the Durable Cache feature flags enabled. - siteId: 'a8ceaa01-86fd-4c9a-8563-3769560d452a', - }), } diff --git a/tests/utils/fixture.ts b/tests/utils/fixture.ts index 461b14a346..18ebb328fd 100644 --- a/tests/utils/fixture.ts +++ b/tests/utils/fixture.ts @@ -336,9 +336,7 @@ export async function uploadBlobs(ctx: FixtureTestContext, blobsDir: string) { ) } -const DEFAULT_FLAGS = { - serverless_functions_nextjs_durable_cache_disable: true, -} +const DEFAULT_FLAGS = {} /** * Execute the function with the provided parameters * @param ctx