This commit is contained in:
2026-07-12 19:46:17 +02:00
parent f7a6104896
commit 2492ca8c25
2 changed files with 76 additions and 54 deletions

View File

@@ -535,6 +535,17 @@ process.on('uncaughtException', err => {
}
return;
}
// Thumbnails (/t/) and covers (/ca/) are static WebP files that never change at a
// given URL — the client appends a ?t= cache-bust param when a thumb is regenerated.
// Without an explicit Cache-Control header, Chromium treats these as uncacheable and
// re-fetches every visible thumbnail on every AJAX navigation, causing severe lag.
// Firefox uses a more lenient heuristic and caches them anyway — hence the difference.
if (req.url.pathname.match(/^\/(t|ca)\//)) {
res.setHeader('Cache-Control', 'public, max-age=31536000, immutable');
} else if (req.url.pathname.match(/^\/(b|a|memes)\//)) {
// Full-size images and avatars: cache for 1 hour, re-validate after
res.setHeader('Cache-Control', 'public, max-age=3600');
}
return;
}
const availableThemes = cfg.websrv.themes || ['amoled', 'atmos', 'f0ck', 'f0ck95d', 'iced', 'orange', 'p1nk', '4d'];