From acbd61bee382d1e1659ca5ec76763b19d7b22fce Mon Sep 17 00:00:00 2001 From: Fabricio Silva Date: Wed, 1 Jan 2025 22:57:03 +0000 Subject: [PATCH] set cache max-age --- server.js | 6 +++++- src/routes.js | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 43f7aa7..6395477 100644 --- a/server.js +++ b/server.js @@ -8,7 +8,11 @@ import { IS_PROD, BIND, PORT, LIMIT_SIZE } from "./src/constants.js"; const app = new Koa(); // static server -app.use(serve(IS_PROD ? "./static/dist" : "./static")); +app.use( + serve(IS_PROD ? "./static/dist" : "./static", { + maxAge: 2592000 * 1000, // 30d in milliseconds + }) +); // views render(app, { diff --git a/src/routes.js b/src/routes.js index 9cf97df..aa39810 100644 --- a/src/routes.js +++ b/src/routes.js @@ -32,6 +32,7 @@ router.get("/:uuid{.:ext}", async (ctx, next) => { return await ctx.render("view", gist); } + ctx.set("Cache-Control", "max-age=2592000"); // 30d in seconds ctx.set("X-IV", gist.iv); ctx.body = Buffer.from(gist.cipherText); }); -- 2.51.2