@netlify/cache 3.1.1 → 3.3.0
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/dist/main.cjs +3 -1
- package/dist/main.d.cts +4 -0
- package/dist/main.d.ts +4 -0
- package/dist/main.js +3 -1
- package/package.json +4 -4
package/dist/main.cjs
CHANGED
|
@@ -338,6 +338,7 @@ var fetchWithCache = async (requestOrURL, optionsOrCacheSettings, cacheOptionsPa
|
|
|
338
338
|
if (cached) {
|
|
339
339
|
return cached;
|
|
340
340
|
}
|
|
341
|
+
const { fetch = globalThis.fetch } = cacheOptions;
|
|
341
342
|
const fresh = await fetch(request);
|
|
342
343
|
if (!fresh.body) {
|
|
343
344
|
return fresh;
|
|
@@ -346,7 +347,8 @@ var fetchWithCache = async (requestOrURL, optionsOrCacheSettings, cacheOptionsPa
|
|
|
346
347
|
const clientResponse = new Response(clientStream, fresh);
|
|
347
348
|
const cacheResponse = new Response(cacheStream, fresh);
|
|
348
349
|
applyHeaders(cacheResponse.headers, cacheHeaders(cacheSettings));
|
|
349
|
-
const cachePut = cache.put(request, cacheResponse)
|
|
350
|
+
const cachePut = cache.put(request, cacheResponse).catch(() => {
|
|
351
|
+
});
|
|
350
352
|
if (onCachePut) {
|
|
351
353
|
await onCachePut(cachePut);
|
|
352
354
|
} else {
|
package/dist/main.d.cts
CHANGED
|
@@ -142,6 +142,10 @@ type CacheOptions = CacheSettings & {
|
|
|
142
142
|
* set, a cache without a name (i.e. `""`) will be used.
|
|
143
143
|
*/
|
|
144
144
|
cache?: NetlifyCache | string;
|
|
145
|
+
/**
|
|
146
|
+
* A custom `fetch` implementation to be used instead of the native one.
|
|
147
|
+
*/
|
|
148
|
+
fetch?: typeof globalThis.fetch;
|
|
145
149
|
/**
|
|
146
150
|
* When `fetchWithCache` fetches a new response and adds it to the cache, the
|
|
147
151
|
* `Promise` it returns waits for both the network call to finish and for the
|
package/dist/main.d.ts
CHANGED
|
@@ -142,6 +142,10 @@ type CacheOptions = CacheSettings & {
|
|
|
142
142
|
* set, a cache without a name (i.e. `""`) will be used.
|
|
143
143
|
*/
|
|
144
144
|
cache?: NetlifyCache | string;
|
|
145
|
+
/**
|
|
146
|
+
* A custom `fetch` implementation to be used instead of the native one.
|
|
147
|
+
*/
|
|
148
|
+
fetch?: typeof globalThis.fetch;
|
|
145
149
|
/**
|
|
146
150
|
* When `fetchWithCache` fetches a new response and adds it to the cache, the
|
|
147
151
|
* `Promise` it returns waits for both the network call to finish and for the
|
package/dist/main.js
CHANGED
|
@@ -303,6 +303,7 @@ var fetchWithCache = async (requestOrURL, optionsOrCacheSettings, cacheOptionsPa
|
|
|
303
303
|
if (cached) {
|
|
304
304
|
return cached;
|
|
305
305
|
}
|
|
306
|
+
const { fetch = globalThis.fetch } = cacheOptions;
|
|
306
307
|
const fresh = await fetch(request);
|
|
307
308
|
if (!fresh.body) {
|
|
308
309
|
return fresh;
|
|
@@ -311,7 +312,8 @@ var fetchWithCache = async (requestOrURL, optionsOrCacheSettings, cacheOptionsPa
|
|
|
311
312
|
const clientResponse = new Response(clientStream, fresh);
|
|
312
313
|
const cacheResponse = new Response(cacheStream, fresh);
|
|
313
314
|
applyHeaders(cacheResponse.headers, cacheHeaders(cacheSettings));
|
|
314
|
-
const cachePut = cache.put(request, cacheResponse)
|
|
315
|
+
const cachePut = cache.put(request, cacheResponse).catch(() => {
|
|
316
|
+
});
|
|
315
317
|
if (onCachePut) {
|
|
316
318
|
await onCachePut(cachePut);
|
|
317
319
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/cache",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "TypeScript utilities for interacting with the Netlify cache",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -68,13 +68,13 @@
|
|
|
68
68
|
},
|
|
69
69
|
"author": "Netlify Inc.",
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@netlify/dev-utils": "4.
|
|
72
|
-
"@netlify/types": "2.0
|
|
71
|
+
"@netlify/dev-utils": "4.3.0",
|
|
72
|
+
"@netlify/types": "2.1.0",
|
|
73
73
|
"npm-run-all2": "^7.0.2",
|
|
74
74
|
"tsup": "^8.0.0",
|
|
75
75
|
"vitest": "^3.0.0"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@netlify/runtime-utils": "2.
|
|
78
|
+
"@netlify/runtime-utils": "2.2.0"
|
|
79
79
|
}
|
|
80
80
|
}
|