Fix persistent caching: no-store/no-cache headers, SW v4, versioned asset URLs
This commit is contained in:
1 parent
86914a7329
commit
ea20d31217
3 files changed
+15
-5
No files matched your search
@@ -105,6 +105,16 @@ function ensurePushConfigured() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// HTML: never cache (always revalidate so SW/app updates are picked up immediately)
|
||||
app.use('/', (req, res, next) => {
|
||||
if (req.path === '/' || req.path.endsWith('.html')) {
|
||||
res.setHeader('Cache-Control', 'no-store');
|
||||
} else if (req.path.endsWith('.css') || req.path.endsWith('.js') || req.path === '/sw.js' || req.path === '/manifest.json') {
|
||||
// Short-lived cache — browser revalidates every 60 s but still gets a 304 fast
|
||||
res.setHeader('Cache-Control', 'no-cache');
|
||||
}
|
||||
next();
|
||||
});
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
app.get('/healthz', (_req, res) => {
|
||||
|
||||
Reference in new issue
Block a user