fix(cache): explicitly disable caching for most api routes

This commit is contained in:
Matteo Pagliazzi
2020-04-16 17:12:53 +02:00
parent cc7dac47c4
commit bf492933cc
4 changed files with 30 additions and 12 deletions

View 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();
}