A simple, bare minimum service worker that would cache all the requests, and can be used as a boiler plate to immediately take your webapp offline.
Explanation is annotated in the source code - index.js.
For online example see https://boopathi.github.io/sw-cache-all/