Re: [ServiceWorker] Make the Cache API deal with request's redirect mode not being "follow" (#737)

If we do this, how can a site offline a navigation that redirects to a cross-origin resource without CORS headers?

1. `cache.add(redirectingNavUrl, { mode: 'cors', redirect: 'follow' })` fails because redirect does not have CORS header.
2. `cache.add(redirectingNavUrl, { mode: 'no-cors', redirect: 'follow' })` succeeds, but the resulting opaque result cannot be passed to `respondWith()` for a navigation.

Today, however, you can offline the original site during install and offline the cross-origin redirect destination using a read-through-cache approach.  You can do:

* `cache.add(redirectingNavUrl, { mode: 'same-origin', redirect: 'manual' })` to store the opaqueredirect.
* The navigation will then follow the redirect and get another service worker for the cross-origin destination.  (This doesn't happen in the cases above because skip-serviceworker-flag.)
* That other service worker can offline the final destination.

If we can't store the `opaqueredirect` in Cache, though, then the original site always has to go to network which will fail while offline.

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

Received on Friday, 21 August 2015 14:09:53 UTC