Offline first maps with Calvin Metcalf Hello everyone and welcome to my talk
Special spatial techniques The origional version of this talk was goign to be very map focused
Syncing tile caches and optimizing indices and etc! With things like background syncing tiles and what not
Sorry This is not that talk
spatial isn't special Methods for making all sites work offline are good enough for maps
Defs this is offline first in the sense of mobile first, it won't work offline the first time you go to it, you need connection that first time, it's the idea of designing with offline access as the first priority
Service Workers Service workers are your bread and butter of making things work offline
Seriously just service workers If you do nothing else then service workers, but what are they
a worker they run in seperate threads and communicate via message passing
with a cache with access to a request cache (which is like a box)
able to intercept http requests service workers have access to apis that allow them to intercept and replace all http requests
including other sites this includes other sites, so you can use them on tiles
you can also precache stuff you have flexibility to precache, cache on demand, and even modify the requests or responses
so how does it work when you first go to a site it installes the service worker
one worker for all tabs this only happens once for a given 'scope' so multiple tabs get a single worker
multipe pages this could be for all pages in a given scope i.e. site (we'll get back to this)
event based with promises events are emitted that can be listened for for thinks like:
install when the service worker gets installed, this is when you'd precache stuff
requests when any http request is made, this allows you to intercept it and maybe fulfill it from a cache
upgrade when a new version of the service worker is available so how can they be used
fallback at the very basic a service worker can allow you to just check for responses in a cache and then possible give that back in loo of a request youf can (if you want) put the result of a network request into the cache
push notifications the service worker can be woken up even if the page isn't open (with permision)
serverlessyou can for an advanced case somewhat use a service worker in place of a worker to generate some of the content
danger But I'm not sure I'd rely on ALL sites neccisarily supporting them
Firefox and Chrome only only the non default browsers corently support workers, so I'd not design yoru site to rely on it also of note
multiple pages revisited remember when I said multiple pages? that means you can accedentily install one on the root of all your pages that worked on all pages in that domainwhich could be good, but if you aren't carefully could break stuff far and wide
must be https it must be in https, this shouldn't be a problem
let's encrypt as you really don't have any exuse these days, espeicially as geolocation also requires https these days
Resources: some resources
fin questions?