cache-control config
This commit is contained in:
committed by
Lloyd Brookes
parent
aa11620b8e
commit
1c57d29b3f
@ -46,7 +46,6 @@ if (options.misc.help) {
|
||||
if (options.server['log-format']) {
|
||||
console.error(ansi.format(err.message, 'red'))
|
||||
}
|
||||
})
|
||||
|
||||
const ws = localWebServer({
|
||||
static: {
|
||||
@ -65,6 +64,7 @@ if (options.misc.help) {
|
||||
log: {
|
||||
format: options.server['log-format']
|
||||
},
|
||||
cacheControl: options.server.cacheControl,
|
||||
compress: options.server.compress,
|
||||
mime: options.server.mime,
|
||||
forbid: options.server.forbid,
|
||||
|
@ -38,6 +38,7 @@ function localWebServer (options) {
|
||||
options = Object.assign({
|
||||
static: {},
|
||||
serveIndex: {},
|
||||
cacheControl: {},
|
||||
spa: null,
|
||||
log: {},
|
||||
compress: false,
|
||||
@ -116,6 +117,13 @@ function localWebServer (options) {
|
||||
middlewareStack.push(etag())
|
||||
}
|
||||
|
||||
/* cache-control headers */
|
||||
if (options.cacheControl) {
|
||||
const cacheControl = require('koa-cache-control')
|
||||
debug('Cache control', JSON.stringify(options.cacheControl))
|
||||
app.use(cacheControl(options.cacheControl))
|
||||
}
|
||||
|
||||
/* mime-type overrides */
|
||||
if (options.mime) {
|
||||
debug('mime override', JSON.stringify(options.mime))
|
||||
|
@ -40,6 +40,7 @@
|
||||
"koa": "^2.0.0",
|
||||
"koa-bodyparser": "^3.0.0",
|
||||
"koa-compose": "^3.1.0",
|
||||
"koa-cache-control": "^1.0.0",
|
||||
"koa-compress": "^1.0.9",
|
||||
"koa-conditional-get": "^1.0.3",
|
||||
"koa-connect-history-api-fallback": "~0.3.0",
|
||||
|
Reference in New Issue
Block a user