From 01ba3676e56c38f797607c2911408f2a093c3233 Mon Sep 17 00:00:00 2001 From: Lloyd Brookes Date: Sun, 15 Nov 2015 15:51:18 +0000 Subject: [PATCH] --no-cache option --- bin/cli.js | 3 ++- lib/cli-options.js | 4 ++++ lib/local-web-server.js | 7 +++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index 11f2a07..93499d4 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -46,7 +46,8 @@ localWebServer({ mime: options.cli.server.mime, blacklist: options.cli.server.blacklist.map(regexp => RegExp(regexp, "i")), proxyRoutes: options.cli.server.proxyRoutes, - spa: options.cli.server.spa + spa: options.cli.server.spa, + 'no-cache': options.cli.server['no-cache'] }).listen(options.cli.server.port, onServerUp) function halt (message) { diff --git a/lib/cli-options.js b/lib/cli-options.js index 0cf45bf..ba1c887 100644 --- a/lib/cli-options.js +++ b/lib/cli-options.js @@ -17,6 +17,10 @@ module.exports = { description: 'Enable gzip compression, reduces bandwidth.', group: 'server' }, { + name: 'no-cache', alias: 'n', type: Boolean, + description: 'Disable etag-based caching.', group: 'server' + }, + { name: 'help', alias: 'h', type: Boolean, description: 'Print these usage instructions', group: 'misc' }, diff --git a/lib/local-web-server.js b/lib/local-web-server.js index df4dbf2..2339e0a 100644 --- a/lib/local-web-server.js +++ b/lib/local-web-server.js @@ -83,8 +83,11 @@ function getApp (options) { }) } - app.use(conditional()) - app.use(etag()) + /* Cache */ + if (!options['no-cache']) { + app.use(conditional()) + app.use(etag()) + } /* mime-type overrides */ if (options.mime) {