mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-02-05 22:48:27 -06:00
fix: set cache-control header on static files
This commit is contained in:
@@ -8,11 +8,21 @@ const plugins = require('./connectors/plugins')
|
||||
const distPath = path.resolve(__dirname, '../dist')
|
||||
const publicPath = path.resolve(__dirname, '../ui-public')
|
||||
|
||||
const CACHE_CONTROL = 'no-store, no-cache, must-revalidate, private'
|
||||
|
||||
module.exports = app => {
|
||||
app.use(express.static(distPath, { maxAge: 0 }))
|
||||
app.use('/public', express.static(publicPath, { maxAge: 0 }))
|
||||
app.use(express.static(distPath, { setHeaders }))
|
||||
app.use('/public', express.static(publicPath, { setHeaders }))
|
||||
app.use('/_plugin/:id/*', plugins.serve)
|
||||
app.use('/_plugin-logo/:id', plugins.serveLogo)
|
||||
app.use('/_addon/:id/*', clientAddons.serve)
|
||||
app.use(fallback(path.join(distPath, 'index.html'), { maxAge: 0 }))
|
||||
app.use(fallback(path.join(distPath, 'index.html'), {
|
||||
headers: {
|
||||
'Cache-Control': CACHE_CONTROL
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
function setHeaders (res, path, stat) {
|
||||
res.set('Cache-Control', CACHE_CONTROL)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user