Contact emails
Spec
https://w3c.github.io/ServiceWorker/#cache-addAll
Summary
The Cache API includes a `cache.addAll()` method that allows a site to fetch and store multiple requests at the same time. The spec and other browsers will reject the operation if duplicate requests are specified in a single method invocation.
Chrome currently allows these calls to complete with the early request being ignored and the later request “winning”. Edge matches Chrome’s behavior, but have indicated they would also like to conform to the spec.
To improve browser interoperability we would like to make `cache.addAll()` reject if there are duplicate requests. We already have the code to do this behind the experimental web features flag in M70. The intent is to add a deprecation message in M71 and then enable the flag by default in M72.
Link to “Intent to Implement” blink-dev discussion
There was no previous intent to implement discussion. We originally implemented the code as a bug fix. We thought since multiple other browsers shipped this restriction it would be safe. However, after seeing anecdotal evidence that some sites were using duplicates we decided to move the bug fix under the experimental web features flag while we collected UseCounter data.
Is this feature supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes.
Demo link
https://cache-addall-duplicate-test.glitch.me/
Debuggability
No changes are necessary to devtools. To aid in debugging the issue, however, the `cache.addAll()` promise will reject with an exception message like:
Cache.addAll(): duplicate requests (https://cache-addall-duplicate-test.glitch.me/?q=foo)
This message is also logged as a console warning starting in M70. Once the removal ships this warning will be removed and replaced with the promise rejection.
Risks
Interoperability and Compatibility
Currently a number of sites accidentally include a duplicate URL in their `cache.addAll()` calls in their service worker install event handlers. These service workers fail to install in Firefox and Safari today. Shipping this removal will make these sites fail to install their service worker on Chrome as well.
Edge: Public Support
Firefox: Shipped in Firefox 39
Safari: Shipped (but I’m not sure which version)
Web developers: No signals.
Ergonomics
The `cache.addAll()` method is typically used in the service worker install event handler. If sites begin triggering rejections in these cases then their service worker will not install.
As far as I know there is not a good use case for using duplicate requests in `cache.addAll()` calls. All of the sites I have seen that do it appear to have accidentally included a duplicate in their list of assets. There is a real downside to permitting these duplicates because it results in wasted bandwidth. Since the browser must handle VARY headers it's not possible to filter out duplicates before fetching the Response from the network.
If a site really wants to make duplicate requests it can do so directly with the `fetch()` function.
Is this feature fully tested by web-platform-tests? Link to test suite results from wpt.fyi.
Yes, there were existing WPT tests and we added a couple more cases to better test VARY header interactions. See:
Note, this shows “experimental” support where the feature flag is enabled in chrome and we pass the tests.
Usage information from UseCounter
This is based on about two weeks of time on dev channel and one week of time on beta channel. If the UseCounter value changes after M70 hits stable we can revise our deprecation and removal plan.
The UseCounter probably includes mostly results from service worker install event handlers. Any use at the time of the service worker installation is counted against all pages controlled by that service worker.
Entry on the feature dashboard
Contact emails
Spec
https://w3c.github.io/ServiceWorker/#cache-addAll
Summary
The Cache API includes a `cache.addAll()` method that allows a site to fetch and store multiple requests at the same time. The spec and other browsers will reject the operation if duplicate requests are specified in a single method invocation.
Chrome currently allows these calls to complete with the early request being ignored and the later request “winning”. Edge matches Chrome’s behavior, but have indicated they would also like to conform to the spec.
To improve browser interoperability we would like to make `cache.addAll()` reject if there are duplicate requests. We already have the code to do this behind the experimental web features flag in M70. The intent is to add a deprecation message in M71 and then enable the flag by default in M72.
Link to “Intent to Implement” blink-dev discussion
There was no previous intent to implement discussion. We originally implemented the code as a bug fix. We thought since multiple other browsers shipped this restriction it would be safe. However, after seeing anecdotal evidence that some sites were using duplicates we decided to move the bug fix under the experimental web features flag while we collected UseCounter data.
The UseCounter probably includes mostly results from service worker install event handlers. Any use at the time of the service worker installation is counted against all pages controlled by that service worker.
Entry on the feature dashboard
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAK7rkMh11nKxhHjh_wZ2_kWSzuVgRGWrJ8s5e6Boz92eaQC9PA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CACj%3DBEgB6f7TfxDmHXjcEDNQdnXpZ-Hz%2B4ayV%3DY7oyeP3m8hvg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/op.zput4hqnrbppqq%40cicero2.linkoping.osa.