From 090cea4121f09f0529ac79fee8b67663cc263ecd Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 18 Nov 2026 07:58:36 -0500 Subject: [PATCH] fix: Revalidate cached locale catalogs after upgrades (#14632) --- server/routes/assets.ts | 4 +++- server/routes/index.test.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/server/routes/assets.ts b/server/routes/assets.ts index 9520b079e7..ff6e57d31a 100644 --- a/server/routes/assets.ts +++ b/server/routes/assets.ts @@ -84,7 +84,9 @@ router.get("/locales/:lng.json", async (ctx) => { const locale = await loadClientLocale(lng); - ctx.set("Cache-Control", `public, max-age=${7 * Day.seconds}`); + // "no-cache" still caches, but the browser must revalidate the ETag before + // reuse, as locale URLs do not change between releases. + ctx.set("Cache-Control", "public, no-cache"); ctx.set("ETag", locale.etag); ctx.set("Access-Control-Allow-Origin", "*"); ctx.type = "application/json"; diff --git a/server/routes/index.test.ts b/server/routes/index.test.ts index d85e54be38..0fba7bfb05 100644 --- a/server/routes/index.test.ts +++ b/server/routes/index.test.ts @@ -474,11 +474,11 @@ describe("content security policy", () => { }); describe("/locales/:lng.json", () => { - it("should serve the translation file with cache headers", async () => { + it("should require revalidation before reusing a cached translation", async () => { const res = await server.get("/locales/en_US.json"); expect(res.status).toEqual(200); expect(res.headers.get("content-type")).toContain("application/json"); - expect(res.headers.get("cache-control")).toEqual("public, max-age=604800"); + expect(res.headers.get("cache-control")).toEqual("public, no-cache"); expect(res.headers.get("etag")).toBeTruthy(); expect(res.headers.get("access-control-allow-origin")).toEqual("*"); const body = await res.json();