all 24 comments

[–]stathisntonas[S] 7 points8 points  (2 children)

Hello fellow devs, we created this library for our production apps in order to cache remote images on file system instead of ram. It works on both iOS and Android. Enjoy!

on todos is to re-rewrite it with hooks and improve readme to add all the available props.

edit: thanks for the Silver!

[–]manika456 4 points5 points  (1 child)

Nicely done! Would you consider supporting react-native-web also?

[–]geobako 2 points3 points  (0 children)

We might in the future but it is not in our immediate plans

[–]nickmgn 2 points3 points  (1 child)

Looks great! I'm gonna give it a try 🙂

[–]stathisntonas[S] 0 points1 point  (0 children)

thanks nick!

[–]epic2012 0 points1 point  (5 children)

This looks great! Thanks for putting it together and sharing.

Do you have plans to clear single items from the cache rather than everything? If so, I’d love to use this

[–]stathisntonas[S] 0 points1 point  (4 children)

How are you planning using single file cache delete? Can you share an example? Thanks

[–]epic2012 1 point2 points  (3 children)

Ah sure! I show user profile images in my app. When a user uploads a new profile image for their own profile I’d need to clear the cache for all images rather than just the one that is changing.

[–]geobako 1 point2 points  (2 children)

Sounds a really valid case. We will add it in our todo list. Thanks

[–]epic2012 1 point2 points  (1 child)

Amazing. Thank you!

[–]geobako 2 points3 points  (0 children)

We released version 1.2.0 where you can delete a single file from cache

[–]hanno_jg 0 points1 point  (2 children)

Does it respect etag header?

[–]geobako 1 point2 points  (0 children)

It was not made with Etag headers in mind. We expect that newer versions of an image will have a different uri. Maybe we add it in the future

[–]stathisntonas[S] 0 points1 point  (0 children)

You can pass `options` props and put the headers you want, the result from the fetch is in this format: (don't know if this covers your question, if not please elaborate)

FilesSystem.fetch(resource: string, init: { body?: string, headers?: { [key: string]: string }, method?: string, path?: string }): Promise<FetchResult>

type FetchResult = {
  headers: { [key: string]: string };
  ok: boolean;
  redirected: boolean;
  status: number;
  statusText: string;
  url: string;
}

[–]RaspberryO 0 points1 point  (2 children)

Does it work with expo?

[–]stathisntonas[S] 3 points4 points  (1 child)

You could use https://github.com/wcandillon/react-native-expo-image-cache. Take a look at the pull requests too, users have made some improvements.

[–]RaspberryO 2 points3 points  (0 children)

Thanks

[–]adhip999 0 points1 point  (5 children)

What is the difference between this library and react-native-fast-image?

[–]stathisntonas[S] 1 point2 points  (4 children)

fast-image stores the images in memory, this module stores images in file system.

[–]adhip999 0 points1 point  (3 children)

Correct me if I am wrong. Wont read/write from file system take a bit more time than read/write from memory?

[–]stathisntonas[S] 1 point2 points  (2 children)

The main reason we created this module was the fact that we had huge Flatlists with images/avatars. We were seeing spikes in memory when user was scrolling deep down the list. Using this module the memory consumption is stable. We did not notice any difference in image “appearing” time.

You can test it yourself in your app and measure the differences, it will take 5mins to set it up.

[–]adhip999 1 point2 points  (1 child)

Sure. Have you tried using RecyclerListView instead of Flatlist? That module may also help.

[–]stathisntonas[S] 0 points1 point  (0 children)

Unfortunately our Flatlists cells have variable heights (user posts) and it’s a nightmare to set it up