Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way for a web page to see if their requests will be intercepted by a foreign fetch handler? #1092

Closed
delapuente opened this issue Mar 25, 2017 · 3 comments

Comments

@delapuente
Copy link

Suppose I know my favourite CDN is installing a SW with foreign fetch and I want to wait for downloading other assets until my CDN SW is registered. Is there any API feature to check this?

@mkruisselbrink
Copy link
Collaborator

Not currently, no. You could poll for the presence of a (cooperating) foreign fetch handler by fetching some resource where you have some way of identifying if the request was intercepted or not (foreign fetch handler adding custom header, or just specific content/URL), but there isn't currently any way to wait for the presence of the CDN SW.

You should always be able to deal with the foreign fetch handler not being present though. Even if you somehow determine that at time X there was a foreign fetch handler that gives no guarantees that the handler will still be there for future requests.

The closest to what you're asking for is something like what's discussed in whatwg/fetch#492, providing some way to specify that certain fetches should or should not be served by a service worker.

@delapuente
Copy link
Author

Does it make sense to ask the Service Worker manager if there is some foreign fetch related with certain origins? Such as:

let willBeIntercepted =
  await navigator.serviceWorker.checkInterception('https://fontsite.com');
if (!willBeIntercepted) {
  navigator.serviceWorker.onforeignfetchinterception = evt => {
    willBeIntercepted = evt.origin === 'https://fontsite.com';
  };
}

@jakearchibald
Copy link
Contributor

Closing due to #1188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants