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
Build Curio HMS / build-and-deploy (push) Successful in 48s
Details
This commit is contained in:
parent
c322cf37d5
commit
9c85ed6fb6
|
|
@ -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'));
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue