fix: disable all browser caching for html files in node.js backend to prevent clients from hanging onto completely stale application layouts
Build Curio HMS / build-and-deploy (push) Successful in 48s Details

This commit is contained in:
Deep Koluguri 2026-05-23 23:06:03 -04:00
parent c322cf37d5
commit 9c85ed6fb6
1 changed files with 18 additions and 1 deletions

View File

@ -9,18 +9,35 @@ const port = 3000;
app.use(express.json());
// Serve static files
app.use(express.static(path.join(__dirname, '../')));
app.use(express.static(path.join(__dirname, '../'), {
setHeaders: (res, path) => {
if (path.endsWith('.html')) {
res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
res.setHeader('Pragma', 'no-cache');
res.setHeader('Expires', '0');
}
}
}));
// Primary Routes
app.get('/', (req, res) => {
res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
res.setHeader('Pragma', 'no-cache');
res.setHeader('Expires', '0');
res.sendFile(path.join(__dirname, '../login.html'));
});
app.get('/admin', (req, res) => {
res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
res.setHeader('Pragma', 'no-cache');
res.setHeader('Expires', '0');
res.sendFile(path.join(__dirname, '../admin.html'));
});
app.get('/dashboard', (req, res) => {
res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
res.setHeader('Pragma', 'no-cache');
res.setHeader('Expires', '0');
res.sendFile(path.join(__dirname, '../dashboard.html'));
});