Skip to content

Conversation

@airhadoken
Copy link

This PR covers the use of Service Workers for managing data through can-connect. Service workers are a new technology that allows caching, indexing, and manipulation of data outside the scope of a page, via an installable script.

Service workers operate significantly differently from Web workers in that:

  • Service workers are shared between pages (Service Worker is a subtype of Shared Worker)
  • One service worker controls a set of pages in a scope, rather than one page controlling one or more SWs
  • The Service worker intercepts all fetch requests for the lifetime of the pages it controls, including the HTML itself and all resources loaded.

For SPA creators, the service worker is likely to manage all or a large percentage of resources, especially when dealing with offline access. Having support for the service worker in can-connect allows CanJS to be used more effectively in apps where a service worker is used.

In addition to support for service workers, this PR includes a simple service worker that caches fixtures on demand. when a resource is fixturized via connection.fixturize(), the SW will manipulate the resources for GET/PUT/POST/DELETE itself, without passing the request on to the HTTP host.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant