fix: Revalidate cached locale catalogs after upgrades (#14632)

This commit is contained in:
Tom Moor authored and GitHub committed 2026-11-18 07:58:36 -05:00
1 parent 3d0d24c43d
commit 090cea4121
2 files changed
+5 -3

No files matched your search

+3 -1
View File
@@ -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";
+2 -2
View File
@@ -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();