kfiroo / react-native-cached-image

CachedImage component for react-native
MIT License
938 stars 470 forks source link

Lib is caching but always downloads the image #130

Closed n1xn closed 5 years ago

n1xn commented 5 years ago

After I changed the profileImgUrl I saw that the lib is caching but always downloads the image again. I can see this because I turned airplane-mode on, on my device. Now no image will be shown. I checked by console.log(imgManager.getCacheInfo()) if the images are cached, they are. I tried it in 2 different ways. 1 ist not using the provider at all, the second is using one

No Prodiver used: <CachedImage style={styles.profileImage} source={ this.state.user_profileImgUrl ? this.state.user_profileImgUrl : "" } fallbackSource={require("../../../assets/icons/default_profile_image.png")} />

Provider used: <ImageCacheProvider> <CachedImage style={styles.profileImage} source={ this.state.user_profileImgUrl ? this.state.user_profileImgUrl : "" } defaultSource={ "myUrl" } /> </ImageCacheProvider>

And this is how I am using to get the URL: imgManager .downloadAndCacheUrl(userData.profileImgUrl) .then(imagePath => { if (Platform.OS === "android") { imagePath = "file://" + imagePath; } this.setState({ user_profileImgUrl: imagePath }); }) .catch(() => { });

n1xn commented 5 years ago

switched to:

https://github.com/DylanVann/react-native-fast-image

works like a charm!

n1xn commented 5 years ago

After hours of migrating from this lib to fast-image, I can say this lib made my android version very slow.

amitbravo commented 5 years ago

"this lib made my android version very slow." ? which library you referring react-native-fast-image or react-native-cached-image ?

n1xn commented 5 years ago

This lib, drastically slows down the performance on Android.

So I switched

I have experienced very good performance with React-Native-Fast-Image because it wraps Glide on Android and SDWebImage on iOS.

amitbravo commented 5 years ago

but there is no facility to clear cache with React-Native-Fast-Image https://github.com/DylanVann/react-native-fast-image/issues/267

n1xn commented 5 years ago

For me its performance over Cache control.

But you can implement it yourself, the native libs wraped around this do support clearing cache. So it’s up to you..