cacheable-request
Advanced tools
Comparing version 2.1.0 to 2.1.1
{ | ||
"name": "cacheable-request", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Wrap native HTTP requests with RFC compliant cache support", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -24,3 +24,3 @@ # cacheable-request | ||
- Easily plug in your own or third-party storage adapters | ||
- If DB connection fails, cache is automatically bypassed | ||
- If DB connection fails, cache is automatically bypassed ([disabled by default](#optsautomaticfailover)) | ||
- Adds cache support to any existing HTTP code with minimal changes | ||
@@ -138,2 +138,9 @@ - Uses [http-cache-semantics](https://github.com/pornel/http-cache-semantics) internally for HTTP RFC 7234 compliance | ||
###### opts.automaticFailover | ||
Type: `boolean`<br> | ||
Default: `false` | ||
When set to `true`, if the DB connection fails we will automatically fallback to a network request. DB errors will still be emitted to notify you of the problem even though the request callback may succeed. | ||
##### cb | ||
@@ -140,0 +147,0 @@ |
@@ -37,3 +37,4 @@ 'use strict'; | ||
cache: true, | ||
strictTtl: false | ||
strictTtl: false, | ||
automaticFailover: false | ||
}, opts); | ||
@@ -128,3 +129,3 @@ opts.headers = lowercaseKeys(opts.headers); | ||
get(opts).catch(err => { | ||
if (!madeRequest) { | ||
if (opts.automaticFailover && !madeRequest) { | ||
makeRequest(opts); | ||
@@ -131,0 +132,0 @@ } |
14051
135
190