See https://googlechrome.github.io/samples/service-worker/mock-responses/index.html for a live demo.
Learn more at https://www.chromestatus.com/feature/6561526227927040
This example uses the the service worker to proxy all requests to a process running on 127.0.0.1:80. This can be changed in the worker itself. It doesn't support accessing to an https server.