From ab7c1cfa9201172f4d47ab1dec434d15e383de94 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Mon, 26 Feb 2024 16:59:29 +0000 Subject: [PATCH] Fixed incorrect cache invalidation headers for slugs Admin API endpoint (#19753) closes ENG-666 - the Admin API `GET /slugs/{type}/{slug}/` endpoint is used by Admin to check when a potential slug needs de-duping by adding a `-{x}` suffix. Most often this occurs when setting a draft post title - the endpoint was returning a full-site cache invalidation header meaning hosting services could be blowing away their site caches and needlessly hurting performance because this endpoint is purely a read operation and makes no changes to the site - updated the endpoint to return no cache invalidation header --- ghost/core/core/server/api/endpoints/slugs.js | 2 +- ghost/core/test/e2e-api/admin/slugs.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ghost/core/core/server/api/endpoints/slugs.js b/ghost/core/core/server/api/endpoints/slugs.js index f423824061..cd381d7815 100644 --- a/ghost/core/core/server/api/endpoints/slugs.js +++ b/ghost/core/core/server/api/endpoints/slugs.js @@ -16,7 +16,7 @@ module.exports = { docName: 'slugs', generate: { headers: { - cacheInvalidate: true + cacheInvalidate: false }, options: [ 'include', diff --git a/ghost/core/test/e2e-api/admin/slugs.test.js b/ghost/core/test/e2e-api/admin/slugs.test.js index c939764bc8..8de1f3b9b0 100644 --- a/ghost/core/test/e2e-api/admin/slugs.test.js +++ b/ghost/core/test/e2e-api/admin/slugs.test.js @@ -20,7 +20,7 @@ describe('Slug API', function () { .expect('Cache-Control', testUtils.cacheRules.private) .expect(200); - should.exist(res.headers['x-cache-invalidate']); + should.not.exist(res.headers['x-cache-invalidate']); const jsonResponse = res.body; should.exist(jsonResponse); should.exist(jsonResponse.slugs);