diff --git a/src/presets/netlify/runtime/netlify.ts b/src/presets/netlify/runtime/netlify.ts index 99b978a44d..570af33a12 100644 --- a/src/presets/netlify/runtime/netlify.ts +++ b/src/presets/netlify/runtime/netlify.ts @@ -63,7 +63,7 @@ function getCacheHeaders(url: string): Record { : "must-revalidate"; return { "Cache-Control": "public, max-age=0, must-revalidate", - "Netlify-CDN-Cache-Control": `public, max-age=${maxAge}, ${revalidateDirective}`, + "Netlify-CDN-Cache-Control": `public, max-age=${maxAge}, ${revalidateDirective}, durable`, }; } return {}; diff --git a/test/presets/netlify.test.ts b/test/presets/netlify.test.ts index 7ed26707e8..900eb5d023 100644 --- a/test/presets/netlify.test.ts +++ b/test/presets/netlify.test.ts @@ -87,11 +87,11 @@ describe("nitro:preset:netlify", async () => { `); }); describe("matching ISR route rule with no max-age", () => { - it("sets Netlify-CDN-Cache-Control header with revalidation after 1 year", async () => { + it("sets Netlify-CDN-Cache-Control header with revalidation after 1 year and durable directive", async () => { const { headers } = await callHandler({ url: "/rules/isr" }); expect( (headers as Record)["netlify-cdn-cache-control"] - ).toBe("public, max-age=31536000, must-revalidate"); + ).toBe("public, max-age=31536000, must-revalidate, durable"); }); it("sets Cache-Control header with immediate revalidation", async () => { const { headers } = await callHandler({ url: "/rules/isr" }); @@ -101,11 +101,13 @@ describe("nitro:preset:netlify", async () => { }); }); describe("matching ISR route rule with a max-age", () => { - it("sets Netlify-CDN-Cache-Control header with SWC=1yr and given max-age", async () => { + it("sets Netlify-CDN-Cache-Control header with SWC=1yr, given max-age, and durable directive", async () => { const { headers } = await callHandler({ url: "/rules/isr-ttl" }); expect( (headers as Record)["netlify-cdn-cache-control"] - ).toBe("public, max-age=60, stale-while-revalidate=31536000"); + ).toBe( + "public, max-age=60, stale-while-revalidate=31536000, durable" + ); }); it("sets Cache-Control header with immediate revalidation", async () => { const { headers } = await callHandler({ url: "/rules/isr-ttl" }); @@ -130,7 +132,7 @@ describe("nitro:preset:netlify", async () => { }); expect( (headers as Record)["netlify-cdn-cache-control"] - ).toBe("public, max-age=60, stale-while-revalidate=31536000"); + ).toBe("public, max-age=60, stale-while-revalidate=31536000, durable"); }); } );