Skip to content
Snippets Groups Projects
Commit 57331482 authored by Nayeem Rahman's avatar Nayeem Rahman
Browse files

Clone the response before opening the cache

parent 12f4e0c1
No related branches found
No related tags found
No related merge requests found
......@@ -41,7 +41,8 @@ self.addEventListener("fetch", (event) => {
const requestOptions = { ...event.request, mode: "same-origin" }
const request = new Request(`${origin}${path}`, requestOptions)
response.then(async (response) => {
await (await caches.open(CACHE_NAME)).put(request, response.clone())
const clone = response.clone()
;(await caches.open(CACHE_NAME)).put(request, clone)
})
response = response.catch(async (error) => {
return (await caches.match(request)) || Promise.reject(error)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment