From 11f2dc621751cfefe38645e8e0d59bc89abd01d5 Mon Sep 17 00:00:00 2001 From: Nandakishore Prakash Rao Date: Fri, 12 Jan 2024 10:04:56 +0530 Subject: [PATCH] fix(cache-header): remove deprecated edge control --- server/handlers/cdn-caching.js | 6 ------ test/integration/isomorphic-handler-test.js | 17 ----------------- 2 files changed, 23 deletions(-) diff --git a/server/handlers/cdn-caching.js b/server/handlers/cdn-caching.js index be179cd9..23e54452 100644 --- a/server/handlers/cdn-caching.js +++ b/server/handlers/cdn-caching.js @@ -16,7 +16,6 @@ exports.addCacheHeadersToResult = function addCacheHeadersToResult({ if (cacheKeys) { if (cacheKeys === "DO_NOT_CACHE") { res.setHeader("Cache-Control", "private,no-cache,no-store,max-age=0"); - cdnProviderVal === "akamai" && res.setHeader("Edge-Control", "private,no-cache,no-store,max-age=0"); res.setHeader("Vary", "Accept-Encoding"); res.setHeader( "Content-Security-Policy", @@ -39,14 +38,11 @@ exports.addCacheHeadersToResult = function addCacheHeadersToResult({ "Cloudflare-CDN-Cache-Control", `max-age=${sMaxAge}, stale-while-revalidate=1000, stale-if-error=14400` ); - cdnProviderVal === "akamai" && res.setHeader("Edge-Control", `public,maxage=${sMaxAge}`); } else { res.setHeader( "Cache-Control", `public,max-age=${maxAge},s-maxage=${sMaxAge},stale-while-revalidate=1000,stale-if-error=14400` ); - cdnProviderVal === "akamai" && - res.setHeader("Edge-Control", `public,maxage=${sMaxAge},stale-while-revalidate=1000,stale-if-error=14400`); } res.setHeader("Vary", "Accept-Encoding"); @@ -75,8 +71,6 @@ exports.addCacheHeadersToResult = function addCacheHeadersToResult({ } } else { res.setHeader("Cache-Control", "public,max-age=15,s-maxage=60,stale-while-revalidate=150,stale-if-error=3600"); - cdnProviderVal === "akamai" && - res.setHeader("Edge-Control", "public,maxage=60,stale-while-revalidate=150,stale-if-error=3600"); res.setHeader("Vary", "Accept-Encoding"); res.setHeader( "Content-Security-Policy", diff --git a/test/integration/isomorphic-handler-test.js b/test/integration/isomorphic-handler-test.js index a0b6289b..da0e5b9f 100644 --- a/test/integration/isomorphic-handler-test.js +++ b/test/integration/isomorphic-handler-test.js @@ -607,12 +607,10 @@ describe("Isomorphic Handler", function () { .expect(200) .then((res) => { const cacheControl = res.header["cache-control"]; - const edgeCacheControl = res.header["edge-control"]; const cacheTag = res.header["cache-tag"]; const edgeCacheTag = res.header["edge-cache-tag"]; const contentSecurityPolicy = res.header["content-security-policy"]; assert.equal(cacheControl, "private,no-cache,no-store,max-age=0"); - assert.equal(edgeCacheControl, "private,no-cache,no-store,max-age=0"); assert.equal(cacheTag, undefined); assert.equal(edgeCacheTag, undefined); assert.equal( @@ -650,17 +648,12 @@ describe("Isomorphic Handler", function () { .expect(200) .then((res) => { const cacheControl = res.header["cache-control"]; - const edgeCacheControl = res.header["edge-control"]; const edgeCacheTag = res.header["edge-cache-tag"]; const contentSecurityPolicy = res.header["content-security-policy"]; assert.equal( cacheControl, "public,max-age=15,s-maxage=60,stale-while-revalidate=150,stale-if-error=3600" ); - assert.equal( - edgeCacheControl, - "public,maxage=60,stale-while-revalidate=150,stale-if-error=3600" - ); assert.equal(edgeCacheTag, undefined); assert.equal( contentSecurityPolicy, @@ -697,17 +690,12 @@ describe("Isomorphic Handler", function () { .expect(200) .then((res) => { const cacheControl = res.header["cache-control"]; - const edgeCacheControl = res.header["edge-control"]; const edgeCacheTag = res.header["edge-cache-tag"]; const contentSecurityPolicy = res.header["content-security-policy"]; assert.equal( cacheControl, "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400" ); - assert.equal( - edgeCacheControl, - "public,maxage=900,stale-while-revalidate=1000,stale-if-error=14400" - ); assert.equal(edgeCacheTag, "c/1/abcdefgh"); assert.equal( contentSecurityPolicy, @@ -744,17 +732,12 @@ describe("Isomorphic Handler", function () { .expect(200) .then((res) => { const cacheControl = res.header["cache-control"]; - const edgeCacheControl = res.header["edge-control"]; const edgeCacheTag = res.header["edge-cache-tag"]; const contentSecurityPolicy = res.header["content-security-policy"]; assert.equal( cacheControl, "public,max-age=15,s-maxage=900,stale-while-revalidate=1000,stale-if-error=14400" ); - assert.equal( - edgeCacheControl, - "public,maxage=900,stale-while-revalidate=1000,stale-if-error=14400" - ); assert.equal(edgeCacheTag, "c/1/abcdefgh"); assert.equal( contentSecurityPolicy,