mirror of
https://github.com/outline/outline.git
synced 2026-11-25 07:04:37 +03:00
fix: Revalidate cached locale catalogs after upgrades (#14632)
This commit is contained in:
1 parent
3d0d24c43d
commit
090cea4121
2 files changed
+5
-3
No files matched your search
@@ -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";
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user