diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-12-28 16:29:37 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2021-12-29 17:02:47 +0100 |
commit | 0a8a73c47d8fe0c63425af3ab0394ae52b0f3532 (patch) | |
tree | d467109950b7f75ceffafcf8c5fc2277e30b1605 /server.js | |
parent | 099bc0fc03182e291cf930c7e6d441502934f9b5 (diff) | |
download | server-0a8a73c47d8fe0c63425af3ab0394ae52b0f3532.tar.gz |
Only set cache-control max-age on images and web fonts.
Diffstat (limited to 'server.js')
-rw-r--r-- | server.js | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -79,12 +79,19 @@ function login_delete(res, sid) { * Web server setup. */ +function set_static_headers(res, path) { + if (path.match(/\.(jpg|png|svg|webp|ico|woff2)/)) + res.setHeader('Cache-Control', 'max-age=86400'); + else + res.setHeader('Cache-Control', 'max-age=0'); +} + let app = express(); app.set('x-powered-by', false); app.set('etag', false); app.set('view engine', 'pug'); app.use(compression()); -app.use(express.static('public', { etag: false, maxAge: 24*3600*1000 })); +app.use(express.static('public', { etag: false, cacheControl: false, setHeaders: set_static_headers })); app.use(express.urlencoded({extended:false})); let http_port = process.env.HTTP_PORT || 8080; |