Skip to content

Installing a foreign SW as part of a subresource request #825

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

Closed
jakearchibald opened this issue Jan 27, 2016 · 6 comments
Closed

Installing a foreign SW as part of a subresource request #825

jakearchibald opened this issue Jan 27, 2016 · 6 comments

Comments

@jakearchibald
Copy link
Contributor

Site A has an endpoint that takes an image and compresses it. This could run in a SW and use foreign-fetch to make it available offline to others.

However, if site B tries to use this service, there's no way for it to ensure A's service worker is installed.

Ideally it'd fallback to A's server, but that won't work offline.

Site B, could poll site A, waiting for a serviceworker response rather than a server one (assuming they're different). They could do this hack either when the endpoint is needed, or as part of their install step.

This is fragile, as it assumes that the endpoint is going to try and install a SW using a link header, and that the SW install is going to succeed. Either that or the polling happens indefinitely.

Do we want a better solution here?

fetch(url, { swOnly: true });

If this is client is controlled by a SW, send to SW. Fail if the SW does not provide a response.

Else, if there's a foreign fetch worker scoped to URL, send to that SW. Fail if the SW does not provide a response.

Else, make a head request to URL. If it provides a link header to install a SW in scope of URL, let that SW install and activate, then send the request to that SW. If no SW installs, fails to install, or does not provide a response, fail.

Do we want to allow something like this?

@mkruisselbrink
Copy link
Collaborator

I think eventually we might want something like swOnly and/or skipForeignSW, but I think for an initial version of foreign fetch we don't need either of these flags.

@annevk
Copy link
Member

annevk commented Jan 27, 2016

Yeah I definitely want to give more control to fetch() over what service workers get hit, but we should probably wait a bit until things are deployed and folks come asking for us to iterate. Baby steps.

@wanderview
Copy link
Member

I don't think site B can ever rely on site A's service worker being present. Site A's storage could be revoked after site B thinks its gotten the SW installed.

@mkruisselbrink mkruisselbrink modified the milestone: Version 2 Apr 12, 2016
@delapuente
Copy link

delapuente commented Jun 7, 2016

Sending a manual OPTIONS request (#880) and checking NavigatorOnLine you can know if a foreign service worker is registered so this could act as a shortcut for that in the offline scenario and you could compare response times for heuristically know if there is a service worker in the middle so I think those are shortcuts for already existent features and to have it is something desirable.

@delapuente
Copy link

Related to #1092 ?

@jakearchibald
Copy link
Contributor Author

Closing due to removing foreign fetch.

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

5 participants