As the web is increasingly accessible in more places, so is the fragility of the connection. In this presentation together we will learn about how to progressively enhance the delivery of content with the Service Worker API.
We will cover the notion of offline first as well as a take-away introduction to the Service Worker API through a practical example and demonstration of the code and tools you can use to create an offline experience for your users.
Australia is still a very disconnected country. We have large areas with no data network. So Chris’s example of needing to check a hotel booking on a plane is pretty common and will be a massive issue for many regions as they start getting online.
Expedia’s site stores the user’s most recently accessed information, as it’s likely they will want it again.
Offline First: the next progressive enhancement technique. “Or perhaps it should be ‘unreliable connection first’…”
Don’t think of offline as an error situation – we have responsibility to handle the case. Time will not solve this problem – as time goes on, we won’t suddenly have 100% of people on great connections. As time goes on people connect in more and more different ways.
- reduce reliance on the server
- sync when possible – make use of good connections
- gracefully resolve conflicts
- query device APIs
Great person to follow on this stuff is Jake Archibald. Also check out his book the “offline cookbook” from 2014 (on his website).
Service worker life cycle:
- installation/cache open
- proxy the network
- Chrome and Opera yes, now!
- Firefox soon
- IE under consideration for Edge
- Safari no
(John Allsopp notes afterwards – a great way to influence browser vendors is to use things and show the need and demand. Also as this is an enhancement you don’t have to wait for full coverage to start giving the benefit to people who can use it.)
Q: do any frameworks have good support for service workers?
A: there are some, but in the meantime work on identifying the shell of your app that you should be serving while offline.
Q: any restrictions on what or how much you can cache?
A: pretty much any http request can be handled; noting CORS impacts