summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-12-23 21:57:39 +0100
committerRory& <root@rory.gay>2025-12-23 21:57:39 +0100
commit66ecc9d5bd8767aad354036bc52c8d2a0480b6a3 (patch)
treef1ad497bae72b124d869b3fb6370c2ed91320834
parentFix docker (diff)
downloadserver-ts-66ecc9d5bd8767aad354036bc52c8d2a0480b6a3.tar.xz
Set low cache-control headers for static pages
-rw-r--r--src/api/Server.ts17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/api/Server.ts b/src/api/Server.ts

index 9cc1820f..d371ed9c 100644 --- a/src/api/Server.ts +++ b/src/api/Server.ts
@@ -114,9 +114,20 @@ export class SpacebarServer extends Server { app.use("/imageproxy/:hash/:size/:url", ImageProxy); - app.get("/", (req, res) => res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "index.html"))); - app.get("/verify-email", (req, res) => res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "verify.html"))); - app.get("/widget", (req, res) => res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "widget.html"))); + app.get("/", (req, res) => { + res.set("Cache-Control", "public, max-age=21600"); + return res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "index.html")); + }); + + app.get("/verify-email", (req, res) => { + res.set("Cache-Control", "public, max-age=21600"); + return res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "verify.html")); + }); + + app.get("/widget", (req, res) => { + res.set("Cache-Control", "public, max-age=21600"); + return res.sendFile(path.join(PUBLIC_ASSETS_FOLDER, "widget.html")); + }); app.get("/_spacebar/api/schemas.json", (req, res) => { res.sendFile(path.join(ASSETS_FOLDER, "schemas.json"));