diff options
Diffstat (limited to 'deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/index.js')
-rw-r--r-- | deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/index.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/index.js b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/index.js index 2e9c58c99f..8a5bcab597 100644 --- a/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/index.js +++ b/deps/npm/node_modules/npm-profile/node_modules/make-fetch-happen/node_modules/http-cache-semantics/index.js @@ -221,7 +221,14 @@ module.exports = class CachePolicy { responseHeaders() { const headers = this._copyWithoutHopByHopHeaders(this._resHeaders); - headers.age = `${Math.round(this.age())}`; + const age = this.age(); + + // A cache SHOULD generate 113 warning if it heuristically chose a freshness + // lifetime greater than 24 hours and the response's age is greater than 24 hours. + if (age > 3600*24 && !this._hasExplicitExpiration() && this.maxAge() > 3600*24) { + headers.warning = (headers.warning ? `${headers.warning}, ` : '') + '113 - "rfc7234 5.5.4"'; + } + headers.age = `${Math.round(age)}`; return headers; } @@ -260,6 +267,13 @@ module.exports = class CachePolicy { return isFinite(ageValue) ? ageValue : 0; } + /** + * Value of applicable max-age (or heuristic equivalent) in seconds. This counts since response's `Date`. + * + * For an up-to-date value, see `timeToLive()`. + * + * @return Number + */ maxAge() { if (!this.storable() || this._rescc['no-cache']) { return 0; |