kfiroo / react-native-cached-image

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

How to relate a cached image with a custom key #111

Open jose920405 opened 6 years ago

jose920405 commented 6 years ago

Hello, in advance thank you very much for the module, has been very useful.

I have a problem with some images with cloudinary urls. In my project that url can be customized as you can see in this link.

When I change this url depending on many factors, such as the quality of the internet connection and later use:

<CachedImage
    source={{uri: 'https://res.cloudinary.com/myProy/image/upload/xxxxxxxx/vpdr6bfv2xypjqo7kcky.png' }}
/>

what I think is that it is caching. And if for some reason modify the url and reload it in the same way, I would be caching again a new url for the same image.

This causes an image to be cached as many times as the url is changed.

I would like to know if it is possible to define the name I want to store the reference to an image (For example: id orproductId)

My current Versión.

"react-native-cached-image": "^1.4.3",

react-native info

Environment:
  OS: macOS Sierra 10.12.6
  Node: 8.9.1
  Yarn: 0.24.6
  npm: 5.5.1
  Watchman: 4.7.0
  Xcode: Xcode 8.3.2 Build version 8E2002
  Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed)
  react: 16.0.0 => 16.0.0
  react-native: 0.51.0 => 0.51.0
chrusart commented 6 years ago

Im not sure why you want to do it cause this image parameters actually change the content and it's a different image and should be cached. It's easy to make a PR that you could provide cache key instead of url, but is it something you want really do? With so many parameters mixed cache key logic may be tricky.

jose920405 commented 6 years ago

When the parameters of the url change, it does not create a new image, it only applies filters to the same image, for that reason I do not want to cache it again, I would just like to update the caching that already exists