0

It is about Firebase's local cached data in Android.

If the Android user, has 1-2 years data in Firebase, is there a way to enable, setup, or filter Firebase persistence in local, so that it only create local cache for the last month ?

So we don't the whole data in local cache, but only the last month.

Hendra
  • 115
  • 3
  • 9

1 Answers1

1

The Firebase local cache is not designed to be manually populated. It's managed automatically, and you don't have much control over what gets stored in it. It will store data from recent queries, and it will evict data that hasn't been used. You can't choose which data will or will not be cached - it work with everything or nothing at all.

The local cache is meant to be helpful when the user temporarily loses their network connection. It's not meant for full offline support.

If you need a cache for very specific data that you can control, you will need to build that yourself.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • In this case though it might mean the cache already does precisely what you want. For example, if you only show recent data to the user (by pagination or some other mechanism), the cache will only contain that recent data. And if a user scrolled back to older data, the cache will (also) contain that older data. Which, for that user, might actually be the right behavior. – Frank van Puffelen Jun 19 '20 at 15:23
  • 1
    @FrankvanPuffelen The way I read the question is that they're trying to prune the contents of the cache to only specific data. – Doug Stevenson Jun 19 '20 at 15:28