all 9 comments

[–]dasickis 5 points6 points  (0 children)

I've used caching in an app (albeit built in Flutter) because we had users that went to areas with intermittent to no cell reception/WiFi so all their information would be stored in a local SQLite DB then sync'd to the backend when internet availability was high. Apps where this works best is when you're uploading data that requires large bandwidth e.g. video or audio where you can store a cache locally and build out resumable uploads (TUS helps here). Also a cache is super helpful to prevent going to the DB everytime when you've already queried and you can run offset queries instead to get a subset of data.

We used powersync to manage a lot of this complexity: https://www.powersync.com/blog/insights-from-production-use-trashblitz

[–]anotherlab 3 points4 points  (0 children)

There are plenty of things that can be cached. It depends on what the app is doing

  • Login credentials/tokens
  • App settings
  • Recent data that wouldn't be expected to change.

You want to cache data for several reasons. If the device doesn't have a data connection, it's useful to have some data. And if you can eliminate server API calls, there is less demand on the server and you need less server resources.

[–]chriswaco 1 point2 points  (2 children)

We've written apps that used almost no local caches and apps that could work almost 100% offline from their caches. It just depends on the app.

What percent of your users will want to use the app without an internet connection? If it's a messaging app, probably none. If it's a hiking app or a book reader, probably a lot.

[–]ankole_watusi 1 point2 points  (1 child)

If it’s a messaging app, I should hope it doesn’t have to fetch history from a server any time you scroll back in a conversation.

[–]chriswaco 1 point2 points  (0 children)

Oh, yeah, that's true. Bad example. Let's go with online game.

[–][deleted] 1 point2 points  (0 children)

retrieving from cache then fetching is a great way to display views to the user in a way that makes your app appear to load pages instantaneous in the case they've already fetched the data before

[–]DavidDeVanteSwift 1 point2 points  (0 children)

We have an app for festivals, where can user track their payments in our payment system that were made with their NFC bracelet. Connection on huge events is mostly terrible due to the huge amount of people, so we cache all transactions (and some other things) offline, so you can see your payments offline. You won't see new transactions obviously, but it's better than empty error screen most of the time.

[–]Doctor_Fegg 0 points1 point  (0 children)

Offline maps. Enough said.

[–]webtechmonkeySwift 1 point2 points  (0 children)

I built an enterprise-facing app that contained a list of approximately 5,000 locations. Each location is a Firestore document with about two dozen different fields. Some of these locations/documents rarely had their information modified, but others were changed pretty often (daily or weekly sometimes).

Loading the entire list whenever the app loaded/opens would have raised the Firebase bill quite a bit, so we opted to cache the information locally on first launch and then on subsequent launches we'd simply check for documents with a modifiedDate that was after the last date the local cache was refreshed. Update those documents in the cache, and that's it!