Skip to content

Instantly share code, notes, and snippets.

@ritikrishu
Created March 11, 2018 21:28
Show Gist options
  • Save ritikrishu/5e7986416acefed5f70048adc363b730 to your computer and use it in GitHub Desktop.
Save ritikrishu/5e7986416acefed5f70048adc363b730 to your computer and use it in GitHub Desktop.
searching for an entry in CacheStorage
/**
Suppose, origin has caches named "wittr-static-v8" and "wittr-content-imgs"
"wittr-content-imgs" contains a request response pair for craig.jpg,
with request url as key i.e. "avatars/craig"
*/
console.log(
await caches.match("avatars/craig")
)//👇
/**
body: (ReadableStream)
bodyUsed: false
headers: Headers {}
ok: true
redirected: false
status: 200
statusText: "OK"
type: "basic"
url: "http://localhost:8888/avatars/craig.jpg"
__proto__: Response
*/
console.log(
await caches.match("avatars/craig", {cacheName: "wittr-static-v8"})
)// <- undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment