parchment
parchment copied to clipboard
Service worker
Reopening PR #87, which was closed in the big dist
refactor.
Fixes #6
To test it, edit index.html
and set useServiceWorker = true
. Then, use the Application tab in Chrome to see the service worker register. You can then check the "Offline" button and refresh to see it working offline.
Note that as of right now, the master
branch isn't very useful offline, but if you include my fix for #80, users could go to iplayif.com, click the browser's "install" button to install it locally, and use that to play locally downloaded games offline.
Also note that we're dropping serviceworker.js
in the same directory as the index.html
file, aka the root directory, because otherwise it doesn't work.
To learn about service workers:
- Do Google's free Udacity web course. (You can skip the last bit about IndexedDB.) https://www.udacity.com/course/offline-web-applications--ud899
- Read my blog post https://redfin.engineering/service-workers-break-the-browsers-refresh-button-by-default-here-s-why-56f9417694 (linked above) and its corresponding part 2 https://redfin.engineering/how-to-fix-the-refresh-button-when-using-service-workers-a8e27af6df68
- Rewrite my service worker code from scratch, fixing bugs as you go (and feel free to ask me anything you like). It's only a few dozen lines, but there are a lot of weird failure cases (which you'll encounter while working on the Udacity course); by the time you could write this PR yourself, you'll be ready to merge it.
The server migration seems to have gone ahead successfully, so I'll start moving on this now.