fix(server): avoid caching .js assets in development to fix HMR for safari (#9034)

This commit is contained in:
Daniel Roe 2021-03-23 18:07:35 +00:00 committed by GitHub
parent 2c4cc04b49
commit 1474f14fc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -114,6 +114,12 @@ export default class Server {
if (!this.devMiddleware) {
return next()
}
// Safari over-caches JS (breaking HMR) and the seemingly only way to turn
// this off in dev mode is to set Vary: * header
// #3828, #9034
if (req.url.startsWith(this.publicPath) && req.url.endsWith('.js')) {
res.setHeader('Vary', '*')
}
this.devMiddleware(req, res, next)
})