bv-ui-core 2.9.4 → 2.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bvFetch/index.js +4 -6
- package/package.json +1 -1
package/lib/bvFetch/index.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
/**
|
3
2
|
* @fileOverview
|
4
3
|
* Provides api response caching utilties
|
@@ -133,7 +132,10 @@ module.exports = function BvFetch ({ shouldCache, cacheName, cacheLimit }) {
|
|
133
132
|
.then((cache) => {
|
134
133
|
return cache.match(cacheKey)
|
135
134
|
.then((cachedResponse) => {
|
136
|
-
|
135
|
+
if (!cachedResponse) {
|
136
|
+
this.cachedUrls.delete(cacheKey)
|
137
|
+
return Promise.resolve(null);
|
138
|
+
}
|
137
139
|
const cachedTime = cachedResponse.headers.get('X-Bazaarvoice-Cached-Time');
|
138
140
|
const ttl = cachedResponse.headers.get('Cache-Control').match(/max-age=(\d+)/)[1];
|
139
141
|
const currentTimestamp = Date.now();
|
@@ -167,10 +169,6 @@ module.exports = function BvFetch ({ shouldCache, cacheName, cacheLimit }) {
|
|
167
169
|
// Check if response is available in cache
|
168
170
|
const newPromise = this.fetchFromCache(cacheKey)
|
169
171
|
.then((cachedResponse) => {
|
170
|
-
if (!cachedResponse) {
|
171
|
-
this.cachedUrls.delete(cacheKey)
|
172
|
-
return Promise.resolve(null);
|
173
|
-
}
|
174
172
|
// If response found in cache, return it
|
175
173
|
if (cachedResponse) {
|
176
174
|
return cachedResponse;
|