wcandillon / react-native-img-cache

Image Cache for React Native
https://hackernoon.com/image-caching-in-react-native-96d8df33ca84
Apache License 2.0
732 stars 142 forks source link

ImageCache.get().clear() is not working on CustomCachedImage #89

Closed pavinthan closed 6 years ago

pavinthan commented 6 years ago

CustomCachedImage always show first user image Image url like {DOMAIN_NAME}/api/profile/images/cropped

<CustomCachedImage
     component={Thumbnail}
     large
     source={{
     uri: profileImage(),
     headers: {
        Authorization: oauth.token_type + ' ' + oauth.access_token
     },
}}/>
ImageCache.get().clear().done(() => {
    // some code
});
aalkhulaifi605 commented 6 years ago

I am having the same issue where if the user updated his image on the backend , the app won't load the new image and will always load from cache . Setting it to mutable will fix this issue but the image will not be displayed when the user is offline and the app will always request the image .

Does the lib auto delete cache after their max-age is expiated ? My backend does return cache control with max-age but not sure if the lib will auto delete .

mayur-padshala commented 6 years ago

To your image URI, try adding the user id in query parameter. Example: uri: `${profileImage()}?userId=${user_id}`,

This will make the URLs unique to each user and would help resolve your issue.

pavinthan commented 6 years ago

@Nitroman605 @mayur-novus thanks for your advice, I used /api/profile/images/cropped?uuid={UUID} to fix the issue.

Thanks again.