mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 14:17:22 +01:00
fix(cache): explicitly disable caching for most api routes
This commit is contained in:
14
website/server/middlewares/cache.js
Normal file
14
website/server/middlewares/cache.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import onHeaders from 'on-headers';
|
||||
|
||||
export function disableCache (req, res, next) {
|
||||
res.header('Cache-Control', 'no-store');
|
||||
|
||||
// Remove the etag header when caching is disabled
|
||||
// Unfortunately it's not possible to prevent the creation right now
|
||||
// See this issue https://github.com/expressjs/express/issues/2472
|
||||
onHeaders(res, function removeEtag () {
|
||||
this.removeHeader('ETag');
|
||||
});
|
||||
|
||||
return next();
|
||||
}
|
||||
Reference in New Issue
Block a user