Try to return a response from cache
{ifNoneMatch: true}
{ifMatch: true}
RequestInfo | URL to match
Optional
optional CacheQueryOptions and CacheOptions
name of the cache to match (default: 'default')
Response or undefined
const req = new Request('http://localhost:3000/api/v1/health');const cacheRes = await cacheMatch(req, {ifNoneMatch: true}); // ifNoneMatch: 'if-none-match' header from cached response ETagconst res = await fetch(req);if (res.status === 304) { // 304 Not Modified // use cached response Copy
const req = new Request('http://localhost:3000/api/v1/health');const cacheRes = await cacheMatch(req, {ifNoneMatch: true}); // ifNoneMatch: 'if-none-match' header from cached response ETagconst res = await fetch(req);if (res.status === 304) { // 304 Not Modified // use cached response
v0.0.1
Try to return a response from cache
{ifNoneMatch: true}
is set, we are passing ETag value from cache response to the request 'if-none-match' header for data validation.{ifMatch: true}
is set, we are passing ETag value from cache response to the request 'if-match' header for data validation.