Browse Source

cache-control config

master
Сергей Куликов 9 years ago
committed by Lloyd Brookes
parent
commit
1c57d29b3f
  1. 2
      bin/cli.js
  2. 8
      lib/local-web-server.js
  3. 1
      package.json

2
bin/cli.js

@ -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,

8
lib/local-web-server.js

@ -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))

1
package.json

@ -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",

Loading…
Cancel
Save