3 const cacheMiddleware = {
7 function cache (cache) {
8 return function (req, res, next) {
9 // If we want explicitly a cache
10 // Or if we don't specify if we want a cache or no and we are in production
11 if (cache === true || (cache !== false && process.env.NODE_ENV === 'production')) {
12 res.setHeader('Cache-Control', 'public')
14 res.setHeader('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate')
21 // ---------------------------------------------------------------------------
23 module.exports = cacheMiddleware