cacheable-request
Advanced tools
Comparing version 5.0.0 to 5.1.0
{ | ||
"name": "cacheable-request", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "Wrap native HTTP requests with RFC compliant cache support", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -134,6 +134,13 @@ # cacheable-request | ||
If set to `false`, after a cached resource's TTL expires it is kept in the cache and will be revalidated on the next request with `If-None-Match`/`If-Modified-Since` headers. | ||
If set to `true` once a cached resource has expired it is deleted and will have to be re-requested. | ||
If set to `false` (default), after a cached resource's TTL expires it is kept in the cache and will be revalidated on the next request with `If-None-Match`/`If-Modified-Since` headers. | ||
###### opts.maxTtl | ||
Type: `number`<br> | ||
Default: `undefined` | ||
Limits TTL. The `number` represents milliseconds. | ||
###### opts.automaticFailover | ||
@@ -140,0 +147,0 @@ |
@@ -100,3 +100,8 @@ 'use strict'; | ||
}; | ||
const ttl = opts.strictTtl ? response.cachePolicy.timeToLive() : undefined; | ||
let ttl = opts.strictTtl ? response.cachePolicy.timeToLive() : undefined; | ||
if (opts.maxTtl) { | ||
ttl = ttl ? Math.min(ttl, opts.maxTtl) : opts.maxTtl; | ||
} | ||
await this.cache.set(key, value, ttl); | ||
@@ -103,0 +108,0 @@ } catch (err) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15839
194
205