From 0457b6f3579a00f08891825aee1629cbd1443d76 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Sat, 17 Apr 2021 20:24:07 +0200 Subject: Add cache headers --- index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index 830692b..d8eba17 100644 --- a/index.ts +++ b/index.ts @@ -84,13 +84,15 @@ for await (const req of serve({ port: parseInt(SERVER_PORT), hostname: SERVER_HO if (req.url === "/version.txt") { req.respond({ body: await Deno.readTextFile("version.txt") }); } else if (req.url === "/") { - req.respond({ body: JSON.stringify(await getRepositories()) }); + const headers = new Headers(); + headers.append("Cache-Control", "public,no-transform,max-age=3600"); + headers.append("Expires", new Date().toUTCString()); + req.respond({ body: JSON.stringify(await getRepositories()), headers: headers }); } else { req.respond({ status: 404 }); } - } catch(err) { req.respond({ body: JSON.stringify(err) }); } -- cgit v1.3