A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.

To request an account, ask an autoconfirmed user on Chat (such as one of these permanent autoconfirmed members).

Install-less Service Workers

From WHATWG Wiki
Revision as of 22:30, 14 July 2015 by Ehsan (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This is a proposal for allowing usage of service workers without installing them. This will be useful for APIs such as Push, and Background Sync. FetchEvent will not be dispatched to such service workers. The script source for these service workers wouldn't be cached locally (except for perhaps in the HTTP cache as all other resources) so every time that the UA wants to spin up one of these, it needs to potentially load it from the network.

Changes to Service Workers

The RegistrationOptions dictionary would need to be extended like this:

dictionary RegistrationOptions {
  USVString scope;
  boolean install;
};

The Register algorithm would need to be modified around step 4.2 to treat install: false specially by not doing nothing when an existing worker has been installed for that scope (and maybe reusing it, that requires more thought) and skip running the Update algorithm.

Furthermore, the current definition of registrations heavily depends on the workers being installed, and we would need to perhaps have a parallel list of workers that have been registered in this new mode. We need to figure out how to treat the intersection of these two sets.

We can probably expose a new readonly boolean attribute on ServiceWorkerRegistration like installed to be able to return a ServiceWorkerRegistration object from register() for the install: false case that will have slightly different semantics (such as never having an installing and waiting worker, its update() method not doing anything, else) but this will have the nice property that the Push API hooks and the similar can work with both types of workers.