aboutsummaryrefslogtreecommitdiffstats
path: root/index.ts
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2021-04-17 20:24:07 +0200
committerivarlovlie <git@ivarlovlie.no>2021-04-17 20:24:07 +0200
commit0457b6f3579a00f08891825aee1629cbd1443d76 (patch)
tree7a047e162b7eac039414b4201c756441b7106ae9 /index.ts
parent6cff1bba7d6be3818547b40cc9965f4b2ba73711 (diff)
downloadsrht-git-feed-0457b6f3579a00f08891825aee1629cbd1443d76.tar.xz
srht-git-feed-0457b6f3579a00f08891825aee1629cbd1443d76.zip
Add cache headers
Diffstat (limited to 'index.ts')
-rw-r--r--index.ts6
1 files 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) });
}