Offline with service worker

I’ve been working on a progressive web app with Ionic 2 and thought i’d see how the whole service worker thing was working, but didn’t - at all.
When i visit the page in the browser and turn off my internet i just get the default chrome not online message. When i visit the page with internet and look at the console output it notes the service worker and being installed but there’s always a “no response for…” on all of the static files.

I though it was just (pretty much) plug and play with ionic?

I’ve uncommented the server worker script in my index.html

Is there anything else i need to do? The documentation doesn’t seem to contain anything in regards to these features specific to PWA

The service-worker.js included in a project generated with the Ionic CLI is the same as the Read-through Caching sample from Google Chrome, and works fine for basic needs where you want to cache all requests.

Why it’s not working for you I cannot know from your post. How are you testing it for a start?

As always, it’s better if you understand what you’re doing rather than rely on things to work out of the box. Service Workers: an Introduction is a good starting point.

1 Like

this is really helpful, thanks so much.

is this sample still viable for ionic 3.9.2/angular 5 ?