Home > Net >  Flutter: Does Firebase Storage cache my images?
Flutter: Does Firebase Storage cache my images?

Time:02-04

In my Flutter app, I have pages with multiple user profile images. Sometimes 20 of the same user profile image. For every image, I fetch the download URL from Firebase Storage and use a FadeInImage. Will Firebase Storage count every image as a download or do the images get saved to the cache and automatically reused?

In other words: Do I need to worry about saving the images to cache myself to reduce downloads and costs or does Firebase do that for me?

CodePudding user response:

do I need to worry about saving the images to cache myself to reduce downloads or does Firebase do that for me?

If you're reading files from Storage, it doesn't mean that they will be automatically cached on your device.

To solve this you have to find a solution for caching, so you don't need to use bandwidth each time you display an image. For Flutter I recommend you check the accepted answer from the following post:

CodePudding user response:

I cannot find any documentation that currently shows any data being cached, but flutter has plenty of libraries that can help with that, I personally use the extended image library https://pub.dev/packages/extended_image that can cache any image fetched on the network with very simple code.

CodePudding user response:

Are you trying to reduce bandwidth costs for Firebase storage or for users so they don't have to download same images every time? If for users, then you'll have to cache them yourselves and write your own logic to purge the files as needed.

Alternatively, consider using Cloud CDN, where egress charges are lower compared to Firebase storage and it would also speed up download speed significantly for end users. It'll also be useful to purge cache programmatically using Cloud Functions/backend when a user updates their profile image.

Also see Firebase storage extremely slow fetching.

  • Related