From 5bafe0865f518e4926fc41fec21064e894367fdb Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 22 Dec 2023 14:00:51 +0100 Subject: Tweak Cache-Control behavior. Add experimental /clear-cache page. --- server.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 5521c53..ba0de61 100644 --- a/server.js +++ b/server.js @@ -160,9 +160,9 @@ function login_delete(res, sid) { function set_static_headers(res, path) { if (path.match(/\.(jpg|png|svg|webp|ico|woff2)$/)) - res.setHeader("Cache-Control", "max-age=86400") + res.setHeader("Cache-Control", "max-age=86400, must-revalidate") else - res.setHeader("Cache-Control", "max-age=60") + res.setHeader("Cache-Control", "no-cache") } let app = express() @@ -385,6 +385,11 @@ app.get('/', function (req, res) { res.render('index.pug', { user: req.user }) }) +app.get("/clear-cache", function (req, res) { + res.setHeader("Clear-Site-Data", `"cache"`) + res.send("Did it work?") +}) + app.get('/create', function (req, res) { res.render('create-index.pug', { user: req.user }) }) -- cgit v1.2.3