WelcometoMyGarden/welcometomygarden

Support actual offline mode on web

th0rgall opened this issue · 0 comments

See this commit e750fb3

The intention was that every GET the app sends via fetch would be cached, that includes SvelteKit routes, several Firebase calls, Mapbox tiles, ... but to prevent stale cache problems, these caches would only be used in case of a fetch error on assumed network loss.

The problem is that they're useless for now when the network is down. Nothing loads. The app depends largely on Firebase to be able to initialize and operate, and Firebase presumably uses a WebSocket for transportation (https://stackoverflow.com/questions/49156783/transport-protocols-firebase-realtime-database-uses) which can't be cached by the SW (https://stackoverflow.com/a/39602235/4973029)

So we were storing up to hundreds of MBs on user's browsers without providing any offline functionality for it.

It is possible though, and could be useful for:

  • viewing your existing chat messages while offline
  • browsing the static rules/information while offline
  • ability to navigate to different pages in the app when the internet connection is bad or intermittent, without seeing errors.

But much more thought needs to go into this:

  • https://firebase.google.com/docs/firestore/manage-data/enable-offline is important, and can be used on the web. We need to consider what a user might want to access while offline, and preload that data, e.g. chats, gardens.
  • #309 would also be helpful, because static pages like the rules page or homepage that don't critically depend on Firebase being logged/in should überhaupt not be blocked to load offline by Firebase support. They could easily be cached by a service worker when SSR is enabled.
  • Map tiles could be cached by a service worker, but we need to understand what to cache. Care needs to be taken that these should caches also expire at some point.