Open
Description
Hi there!
By default, express does not serve no-cache headers on routes, so for instance:
import * as express from 'express'
const app = express()
app.get('/', (_req, res) => {
res.send('Hello')
})
app.listen(3000)
Results in the following:
curl -I localhost:3000
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: text/html; charset=utf-8
Content-Length: 5
ETag: W/"5-9/+ei3uy4Jtwk1pdeF4MxdnQq/A"
Date: Thu, 15 Nov 2018 22:53:08 GMT
Connection: keep-alive
This is missing Cache-Control: no-cache
, Pragma: no-cahe
or Expires: 0
headers that would inform the browser that the result of the request should not be cached.
My suggestion is to serve these files with no-cache headers by default, like serve-static. This will reduce the chance that folks will forget to configure it, and end up potentially having clients hang on to stale code.
(this is an issue I've recently run into on my project -- it seems that sometimes browsers do cache such responses when no cache headers are provided)
Thanks for your hard work!