0.9.1 • Published 6 years ago

sw-proxy v0.9.1

Weekly downloads
7
License
Apache-2.0
Repository
github
Last release
6 years ago

Build Status

HTTP Proxy Proof-of-Concept

This is not an official Google product!

Motivation

Perhaps surprisingly, the service worker cache does not behave like a standard HTTP cache; http-proxy.js attempts to implement an RFC 7234 and RFC 5861 compliant HTTP proxy suitable for use within a service worker.

Some reasons for investigating this:

  • Is it possible to polyfill HTTP features browsers don't support? Browsers support some, but not all, of the standard cache control headers. For example, no browser implements stale-while-revalidate or stale-if-error (though stale-while-revalidate may arrive in Chrome at some point). Is it possible to provide a useful polyfill for these cache control headers? (This may be particularly useful in the future if foreign fetch is implemented.)
  • Is it possible to implement different caching strategies on top of HTTP? HTTP has sophisticated, well-defined, and well-understood caching features, and so it might make sense to implement different caching strategies via simple header-manipulating wrappers on top of a generic HTTP proxy, instead of writing strategy-specific cache manipulation code with a custom configuration language. Is this a viable approach?

Examples (currently broken)

To view the examples:

$ yarn # or npm install
$ yarn start
# open http://127.0.0.1:8000/

Recommendations:

  • Keep the "server" terminal window open to see when requests are really made.
  • Open DevTools.
  • Turn on network throttling to the slowest speed.

Notes:

  • The cache and service workers are reset every time index.html is loaded.
  • The examples are initiated via an interstitial page that installs and activates the service worker. This is slightly ugly, but it makes the examples a lot easier to follow.

Tests

There aren't many tests at the moment, but what tests there are can be run via:

$ yarn test # or npm test

Author

Michael Stillwell <mjs@beebo.org>

0.9.1

6 years ago

0.9.0

7 years ago

0.8.0

7 years ago

0.7.0

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago