Is there a way to set the Cache-Control property per files in your ExpressJS app ? I would like a granular control over the caching of the files in my app... how can i achieve this ? Whats the best practises in regards to Cache-Control ?
app.use(function (req, res, next) {
if (req.url.match(/* some filter */)) {
res.setHeader('Cache-Control', ...)
} else if (req.url.match(/* some filter */)) {
res.setHeader('Cache-Control', ...)
}
next()
})
app.use(express.static(__dirname + '/public'))
No need to make it complicated.
response.setHeader('Cache-Control', '...');
Can you explain more about which files need to set this? I'm guessing middleware is your best bet for controlling this, but need more info about how and when you'd like to control it.