Re: [ServiceWorker] Concerns about `cache.addAll` not filtering non-200 (#407)

Hmm, having it on request would avoid the…

```js
fetch(url).then(response => {
  if (!response.ok) throw Error("NAH");
  // etc
})
```

…boilerplate. It would make the cache code:

```js
cache.addAll(
  urls.map(u => new Request(u, {ensureOk: true}))
);
```

…which is a bit more verbose, but it would allow:

```js
cache.addAll([
  '/hello/',
  '/world/',
  new Request('//other-origin/blah.txt', {mode: 'no-cors'})
].map(request => {
  if (request instanceof Request) return request;
  return new Request(url, {ensureOk: true});
}));
```

…meaning you could mix `ensureOk` requests with others.

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/407#issuecomment-92425679

Received on Monday, 13 April 2015 17:04:54 UTC