1
0
Fork 0
forked from fedi/mastodon

Clone response before put it to the cache (#6932)

`Response.prototype.clone()` must be called before the response used.

This fixes an error from ServiceWorker and failing to load image when the
image is not cached.
This commit is contained in:
unarist 2018-03-27 22:18:35 +09:00 committed by Eugen Rochko
parent 2f3ac14a43
commit f5ed5f3860

View file

@ -56,10 +56,10 @@ self.addEventListener('fetch', function(event) {
const fetched = await fetch(event.request);
if (fetched.ok) {
await cache.put(event.request.url, fetched);
await cache.put(event.request.url, fetched.clone());
}
return fetched.clone();
return fetched;
}
return cached;