nbn-upgrade-map icon indicating copy to clipboard operation
nbn-upgrade-map copied to clipboard

Create Service Worker

Open LukePrior opened this issue 2 years ago • 4 comments

Will allow site to load quicker and work offline with stored data when installed as a PWA.

Caching Strategy:

  • Map tiles (keep for 30 days)
  • historical NBN info (keep indefinitely)
  • main/current NBN info (fetch every time or maybe keep for a few hrs max)
  • JavaScript files and others (30 days?)

https://stackoverflow.com/questions/46036897/best-practices-for-detecting-offline-state-in-a-service-worker https://developer.chrome.com/docs/workbox/caching-strategies-overview/

LukePrior avatar Nov 12 '23 08:11 LukePrior

Got this for now: https://github.com/LukePrior/nbn-upgrade-map/blob/main/site/serviceworker.js

LukePrior avatar Nov 12 '23 10:11 LukePrior

Ok hopefully that will work ok, still needs an update to periodically purge caches if nearing storage limits

LukePrior avatar Nov 12 '23 12:11 LukePrior

This might help with https://github.com/LukePrior/nbn-upgrade-map/issues/309

lyricnz avatar Nov 16 '23 23:11 lyricnz

https://github.com/LukePrior/nbn-upgrade-map/issues/309#issuecomment-1822011979

LukePrior avatar Nov 22 '23 03:11 LukePrior