GoogleChromeLabs / sw-toolbox

[Deprecated] A collection of service worker tools for offlining runtime requests
https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
Apache License 2.0
3.62k stars 331 forks source link

service worker not working in dev... How can I make it work in dev? #147

Open jcalvor opened 8 years ago

jcalvor commented 8 years ago

HI, I followed all the steps for the service worker but it doesn't work. should also manipulate the cache-config.json file? I was also watcing a video from the google developers channel (https://www.youtube.com/watch?v=BucGrYACJdQ&list=PLNYkxOF6rcIDdS7HWIC_BYRunV6MHs5xo&index=29) but it seems they use an old version since in the gulp file they are using a 'precache' and the documentation says 'cache-config'. so I am a little confuse...

wibblymat commented 8 years ago

@jcalvor what does your service worker file actually look like? Did you manage to get a simple service worker doing something first, or are you hitting problems straight out of the box?

I recommend that if you are starting with a service worker that does a bunch of complicated precaching that you get something simple going and build up from there.

importScripts('path/to/sw-toolbox.js');

toolbox.options.debug = true;

toolbox.router.get('/test', () => new Response('Test'));

If you use the service worker above (edited to have the real path to toolbox), what happens if you navigate to /test after the service worker has installed?

wibblymat commented 8 years ago

@jcalvor Actually, having read your comment again, can you confirm which project you are actually talking about?