WelcometoMyGarden / welcometomygarden

Web app of Welcome To My Garden, a not-for-profit network of citizens offering free camping spots in their gardens to slow travellers.
https://welcometomygarden.org
GNU Affero General Public License v3.0
107 stars 16 forks source link

Support actual offline mode on web #310

Open th0rgall opened 1 year ago

th0rgall commented 1 year ago

See this commit https://github.com/WelcometoMyGarden/welcometomygarden/commit/e750fb3f6994116382c8a51183f054b0e2781321

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:

But much more thought needs to go into this: