summaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
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 8d4c24b..50fa751 100644
--- a/server.js
+++ b/server.js
@@ -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;