expo-image cacheKey support
complete
Pavlo Huk
URLs like "https://s3.com/cat-image.png?auth=Eadkamo" can not be cached without a custom cache key because they can be changed anytime with a new query parameter.
Suggestion: add new prop cacheKey with possible values - 'uri'/custom string/callback.
Also would be nice to have the ability to set this up on a global level using values from above.
Tomasz Sapeta
complete
X
Xie Zhihao
Tomasz Sapeta: Hi Tomasz, is there any plan to also add a cacheKey option for the prefetch method?
Tomasz Sapeta
The first iteration of this feature is now available in
expo-image@1.0.0-alpha.6
under the new field in the source object called cacheKey
.In the future we'll add more functionalities like the mentioned callback and global setting, but for now I believe this is sufficient to cover most use cases 😉
Pavlo Huk
Tomasz Sapeta: Cool, thanks, that was fast!
Tomasz Sapeta
We quickly looked at native libraries used by expo-image and looks like both SDWebImage and Glide include the url query in the default cache key, so you shouldn't see any issue with such a url 🤔
Anyway, we're going to make it customizable through another value in the image source object 😉
Pavlo Huk
Tomasz Sapeta: Yeah, that's the problem. Providers like S3 use a query for auth and every time it's a different query even though image is the same, so it'll try to download the image again and again because the URL is different (but the image is not)
Tomasz Sapeta
Pavlo Huk: Ah I see, thanks for explanation!
Tomasz Sapeta
in progress
Tomasz Sapeta
Sounds like a good idea! We'll implement that soon 🙂