From 302113baeeccce64df0067fcc41d389cc59dd411 Mon Sep 17 00:00:00 2001 From: Yuri Tatishchev Date: Tue, 17 Jun 2025 00:22:39 -0700 Subject: [PATCH] move cache control to be the first middleware --- src/index.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/index.js b/src/index.js index 18cb2c3..6ee0ae1 100644 --- a/src/index.js +++ b/src/index.js @@ -80,6 +80,14 @@ wss.on('connection', function connection(ws) { //// Web server //// // app settings + +// disable cache globally because it may break things between server restarts, +// since the paths aren't unique +app.use(function (req, res, next) { + res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); + next(); +}); + app.use('/', express.static(__dirname)); app.use(bodyParser.urlencoded({ extended: true @@ -92,13 +100,6 @@ app.use(session({ logged: false })); -// disable cache globally because it may break things between server restarts, -// since the paths aren't unique -app.use(function (req, res, next) { - res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); - next(); -}); - // home page app.get("/", function (req, res) {