Cache HTML/JS/CSS with no-cache revalidation (ETag 304): browsers always get fresh pages after docker restart; vendor and image caches unchanged
This commit is contained in:
@@ -216,9 +216,17 @@ app.get('/uploads/thumb/:name', fileLimiter, async (req, res) => {
|
||||
return sendImageThumb(res, fp);
|
||||
});
|
||||
|
||||
app.use((req, res, next) => {
|
||||
const p = req.path;
|
||||
if (!p.startsWith('/uploads') && !p.startsWith('/vendor')) {
|
||||
res.setHeader('Cache-Control', 'no-cache');
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
app.use('/uploads', express.static(path.join(__dirname, 'uploads'), { maxAge: '365d', immutable: true }));
|
||||
app.use('/vendor', express.static(path.join(__dirname, 'public', 'vendor'), { maxAge: '30d' }));
|
||||
app.use(express.static(path.join(__dirname, 'public'), { maxAge: '1h' }));
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
const SESSION_TTL_MS = 30 * 24 * 60 * 60 * 1000;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user