From 4af36fc9262a84e39622852ae8cf91ce98311da5 Mon Sep 17 00:00:00 2001 From: Gronod Date: Sun, 17 May 2026 08:46:55 +0100 Subject: [PATCH] fix: correct status panel cache stats and static asset caching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cache.js: Map values serialise as '{}' under JSON.stringify, causing emby:users to show 0 bytes and null item count in the status panel. Convert Maps via Object.fromEntries before stringifying, and report Map.size as itemCount. index.js: JS and CSS served with Cache-Control: no-cache so browsers always revalidate on load. ETag still prevents re-downloading unchanged files — only a new deploy triggers an actual download. --- server/index.js | 13 +++++++++++-- server/utils/cache.js | 8 ++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/server/index.js b/server/index.js index 729cbde..f9badcb 100644 --- a/server/index.js +++ b/server/index.js @@ -202,8 +202,17 @@ app.get('/ready', (req, res) => { const PUBLIC_DIR = path.join(__dirname, '../public'); const INDEX_HTML = path.join(PUBLIC_DIR, 'index.html'); -// Serve all static assets (js, css, images, icons) except index.html -app.use(express.static(PUBLIC_DIR, { index: false })); +// Serve all static assets (js, css, images, icons) except index.html. +// JS and CSS get no-cache so browsers revalidate on every load (ETag still +// avoids re-downloading unchanged files; only a deploy changes the ETag). +app.use(express.static(PUBLIC_DIR, { + index: false, + setHeaders(res, filePath) { + if (filePath.endsWith('.js') || filePath.endsWith('.css')) { + res.setHeader('Cache-Control', 'no-cache'); + } + } +})); // Serve index.html with nonce injected into the