diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-11-14 17:53:31 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2021-11-14 17:53:31 +0100 |
commit | b9d5983b17adbd238fdb8a41d926dacf53730675 (patch) | |
tree | 994df12beb4a91d9255aea656050ddc9afda0688 /server.js | |
parent | bf9b4ddafe5d11e510760f6af4479e29da6987ba (diff) | |
download | server-b9d5983b17adbd238fdb8a41d926dacf53730675.tar.gz |
Inline style sheet in EJS template to prevent FOUC.
Diffstat (limited to 'server.js')
-rw-r--r-- | server.js | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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 |