Follow the guideline to cache for http request:
const setCache = (req, res, next) =>{
const period = 5*60;
if(req.method == 'GET')
{
res.setCache('Cache-control', `public, max-age=${period}`)
}else{
res.setCache('Cache-control', 'no-store')
}
next()
}
module.exports = {
setCache
}
set as middleware
app.use(setCache)
0 Comments