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

Basic service worker support (on-demand fixtures) with tests #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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