Part 8—Taking the web offline

41 Provide offline access with Service Worker

Application cache is deprecated. It is quite headache to maintain. Now we use Service Worker to cache offline file.

This feature is in the process of being removed from the Web platform. (This is a long process that takes many years.) Using any of the offline Web application features at this time is highly discouraged. Use service workers instead. — WHATWG spec

Service worker as proxy

Service Worker is a proxy between browser and server. It can do much more than caching files. For example, it can run in background process and push notifications to your device.

The Google Chrome’s github page provides an example code on the offline capatability.

https://googlechrome.github.io/samples/service-worker/custom-offline-page/

Note: But iOS has not supported Service Worker yet, so we still need to rely on the Application Cache to provide offline access in iOS.

License

Provide offline access with Service Worker Copyright © by makzan. All Rights Reserved.

Share This Book

Notice: 2nd edition update is work-in-progress. See update logs for details.