Third-party service providers can deploy
foreign fetch service workers
to intercept cross-origin requests from any client. For example, a web font
provider might want to register a foreign fetch service worker to implement an
advanced offline-first strategy for font requests, with a common cache shared
amongst all its clients.
A new Link: rel="serviceworker" response header facilitates
registering these third-party service workers.
Both foreign fetch itself and the Link: rel="serviceworker"
header are part of an
Origin Trial
starting with Chrome 54, and running through March 2017. To test out a foreign
fetch service worker without requiring the third-party service to sign up for
an origin trial token, you can enable
chrome://flags/#enable-experimental-web-platform-features. (This
is not required to test the demo on this page, which makes a request against
a service that has a valid Origin Trial token.)
You can read about the new functionality in more detail in this post.
Live Output
Try disabling your network connection and then requesting a new number. The
foreign fetch service worker should handle the network failure for you,
and return a hardcoded value of 34.