You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
658 B

  1. 'use strict'
  2. const LocalWebServer = require('../../')
  3. const cacheControl = require('koa-cache-control')
  4. const DefaultStack = require('local-web-server-default-stack')
  5. class CacheControl extends DefaultStack {
  6. addAll () {
  7. return this.addLogging('dev')
  8. .addCacheControl()
  9. .addStatic()
  10. .addIndex()
  11. }
  12. addCacheControl () {
  13. this.add({
  14. optionDefinitions: {
  15. name: 'maxage', type: Number,
  16. description: 'The maxage to set on each response.'
  17. },
  18. middleware: function (options) {
  19. return cacheControl({ maxAge: options.maxage })
  20. }
  21. })
  22. return this
  23. }
  24. }
  25. module.exports = CacheControl