Writing a Service Worker
hacklabo.com
hacklabo.com
Apple has a vested interest in pushing users towards their walled garden for apps, while Google and Mozilla are trying to bring app-like experiences to the browser. There are hints of Safari supporting serviceworkers but I'm not holding my breath.
Highly recommend Alex Russel's talk on progressive web apps as background: https://m.youtube.com/watch?v=x7cfLDFVyHo
I happen to agree that offline-readiness (via service workers) is at the core of whether the open web will continue to be a relevant medium.
And desktop users of Chrome, Firefox, and soon Edge (which has support implemented behind a flag).
Laptops and desktops still benefit, but less so because generally if you sit down to use one of those devices in an area of poor connectivity, you're going to run out of things you can do with your serviceworker's cached content pretty quickly. If you're developing a serviceworker, the improved experience will be most felt by mobile users.
https://github.com/gdnmobilelab/hybrid
If you have an actual iOS app already, then this is of course worse, but if you have something that works nicely as a webpage on Android with ServiceWorkers and you want iOS users to have some option at all, this is probably worth playing with.
All browsers on iOS are wrappers around WKWebView (Safari, for the most part). You can’t release a browser app for iOS that doesn’t use this.
Sure, some browsers will have a more robust experience in adverse network conditions, but the experience once a page has loaded will be identical. It's also difficult to accidentally make the worker a hard dependency of a site, since even supported browsers will load the site without the worker on first visit.
But seriously it is a bummer Safari doesn't support service workers yet. It's possible higher adoption would put more pressure on Apple to add support. In the meantime it can be a great enhancement where it is supported.
I really like that button. I don't know, it just drives home the point that you care that I understood your guide -- which was clear and easy to read.
* Cache css, js and images file
* Defined cached entries page ex index.html, show.html etc..
* Fallback Entries
and it is really simple to use. https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_...
- 100% static
- reasonable dataset size
- amenable url space (a few static files, then a large url
space that could fall back to serving out the index.html
file)
Despite this, the appcache just never worked reliably. It was a crapshoot whether it would actually work offline for any given user, I had to be careful not to permanently cache the appcache itself, and it was just generally inflexible and unpleasant.Also: https://alistapart.com/article/application-cache-is-a-douche...
I don't think this approach here should cost much performance. It is just a thread checking a cache (that will be on disk) on page load.
One of the more gnarly parts of ServiceWorker is having to clean up old caches during a version change. The workbox-build module generates revision hashes for your pre-cached assets and handles any cache clean ups for you.
Service workers have access to Indexeddb but not to local storage. That's something to remember.
[0]: https://developers.google.com/web/updates/2015/12/background...
> Sync events will often complete while the user has a page open to the site, so requiring user permission would be a poor experience. Instead, we’re limiting when syncs can be registered and triggered to prevent abuse. E.g.:
> You can only register for a sync event when the user has a window open to the site.
> The event execution time is capped, so you can’t use them to ping a server every x seconds, mine bitcoins or whatever.
https://github.com/fiatjaf/personal-graphs/blob/6182f5a40fec...
Damn it, if I'm going to have the song stuck in my head all day so should all of you!