summaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-11-14 17:53:31 +0100
committerTor Andersson <tor@ccxvii.net>2021-11-14 17:53:31 +0100
commitb9d5983b17adbd238fdb8a41d926dacf53730675 (patch)
tree994df12beb4a91d9255aea656050ddc9afda0688 /server.js
parentbf9b4ddafe5d11e510760f6af4479e29da6987ba (diff)
downloadserver-b9d5983b17adbd238fdb8a41d926dacf53730675.tar.gz
Inline style sheet in EJS template to prevent FOUC.
Diffstat (limited to 'server.js')
-rw-r--r--server.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/server.js b/server.js
index 470eba9..a6c8394 100644
--- a/server.js
+++ b/server.js
@@ -87,7 +87,14 @@ io.use(passport_socket.authorize({
store: session_store,
}));
-app.use(express.static('public'));
+const is_immutable = /\.(svg|png|jpg|jpeg|woff2)$/;
+
+function setHeaders(res, path) {
+ if (is_immutable.test(path))
+ res.set("Cache-Control", "public, max-age=86400, immutable");
+}
+
+app.use(express.static('public', { setHeaders: setHeaders }));
/*
* MISC FUNCTIONS