@sledge-app/react-instant-search 1.0.64 → 1.0.65
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.
|
@@ -204,13 +204,17 @@ async function getData(url) {
|
|
|
204
204
|
return caches.open(cacheName).then((cache) => {
|
|
205
205
|
return cache.match(url).then((cachedResponse) => {
|
|
206
206
|
const fetchedResponse = fetch(url).then(async (networkResponse) => {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
207
|
+
try {
|
|
208
|
+
const mainUrl = url.split("?")[0];
|
|
209
|
+
const cacheMatches = await cache.matchAll();
|
|
210
|
+
const filteredCaches = await cacheMatches.filter((f) => f.url.includes(mainUrl) && f.url !== url);
|
|
211
|
+
for (const c of filteredCaches) {
|
|
212
|
+
await cache.delete(c.url);
|
|
213
|
+
}
|
|
214
|
+
cache.put(url, networkResponse.clone());
|
|
215
|
+
} catch (error) {
|
|
216
|
+
caches.delete(cacheName);
|
|
212
217
|
}
|
|
213
|
-
cache.put(url, networkResponse.clone());
|
|
214
218
|
return networkResponse;
|
|
215
219
|
});
|
|
216
220
|
return cachedResponse || fetchedResponse;
|