From 1d4c9a5b438f71018f129ccf0b0d394570d4a7d2 Mon Sep 17 00:00:00 2001 From: KhoaZero123 Date: Thu, 8 Sep 2022 16:10:12 +0700 Subject: [PATCH] Support must-revalidate --- index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.js b/index.js index 89afd7e..5765e15 100644 --- a/index.js +++ b/index.js @@ -141,6 +141,10 @@ function SendStream (req, path, options) { ? Boolean(opts.immutable) : false + this._revalidate = opts.revalidate !== undefined + ? Boolean(opts.revalidate) + : false + this._index = opts.index !== undefined ? normalizeList(opts.index, 'index option') : ['index.html'] @@ -866,6 +870,10 @@ SendStream.prototype.setHeader = function setHeader (path, stat) { cacheControl += ', immutable' } + if (this._revalidate) { + cacheControl += ', must-revalidate' + } + debug('cache-control %s', cacheControl) res.setHeader('Cache-Control', cacheControl) }