0.1.2 • Published 8 years ago
whistle.service-worker v0.1.2
whistle.service-worker (中文文档)
As a plugin of whistle, whistle.service-worker tests the effect of service worker for sites which want to use.
Installation
Install packages with npm globally:
$ npm install --global whistle whistle.service-workerSet proxy to 127.0.0.1:8899. Whistle Doc - Proxy Setting may help.
Example
Suppose to test the effect of service worker for Github Help:
- Start whistle:
$ w2 startOpen http://local.whistlejs.com/#rules in browser.
Add following rule to whistle:
help.github.com whistle.service-worker://route=/.*/&strategy=cacheFirst
- Open Github Help in new tab and check whether service worker is registered in devtools.

- Refresh Github Help and check network pannel in devtools.

Doc
The key point for users is to set whistle rules like /help.github.com/ whistle.service-worker://route=/.*/&strategy=cacheFirst :
help.github.commeans the hostname of the site to test.route=/.*/means to interception request which's url matches RegExp/.*/by service worker.strategy=cacheFirstis to set a caching strategy. The built-in strategies are:- cacheFirst
- cacheOnly
- networkFirst
- networkOnly
- staleWhileRevalidate