react-native-expo-image-cache icon indicating copy to clipboard operation
react-native-expo-image-cache copied to clipboard

Cache validation and management?

Open brunoreis opened this issue 7 years ago • 3 comments

This seem to be a very nice component. I'm studying it to use and want to understand it a little more. In that direction I would be grateful if someone can answer me those two questions:

1 - Is there a way to invalidate cache in the situation I have an image and upload another one to the server with the same name?

2 - Is there a way to clear old unused cached images? Let's say I had some images of elements that are not used anymore. Or that the cache gets full and I need to remove old/unused images.

brunoreis avatar Aug 25 '18 20:08 brunoreis

Hello @brunoreis 🙌🏻

  1. This component is 100% based on the assumption that images for the exact same URI are immutable. For some cases you might want to invalidate cache from time to time (I wrote about it at https://hackernoon.com/image-caching-in-react-native-96d8df33ca84). However this component only supports the immutable case and we strongly recommend that you design your application service around this constraint. We noticed that if you are using Firebase, is this absolutely not a problem performance wise.

  2. Currently we store the images in the cache folder assuming that the phone operating system will take care of it for us. When starting the app, you can also clear the cache as a background task from time to time. I would be open to use a better strategy if one is suggested to me.

Thank you for gettingh in touch and happy hacking

wcandillon avatar Aug 28 '18 12:08 wcandillon

Thanks Willian. It's important to me knowing these assumptions to use the component.

brunoreis avatar Aug 28 '18 13:08 brunoreis

Thanks @wcandillon. This is a great component even without mutable image support. Support for automatically fetching the new image at the same url and updating local cache would make it even more useful. If performance is a concern, this feature could be disabled by default. Please consider if adding it.

pankajdpatil avatar Feb 23 '21 06:02 pankajdpatil