react-native icon indicating copy to clipboard operation
react-native copied to clipboard

feat(image): enabling basic cache control for android

Open mateoguzmana opened this issue 4 months ago • 2 comments

Summary:

Fixes #12606

Previously, Image cache control options were not functional on Android, even though they were being passed to the native component via the source prop. This PR addresses that by implementing logic to manage cache behaviour on Android.

When the reload option is explicitly set, the image is now evicted from both memory and disk caches before a new request is made. This ensures the image is always fetched from the source, aligning the caching behaviour between Android and iOS for the default and reload options.

Changelog:

[ANDROID][ADDED] - Enabling basic Image cache control for Android

Test Plan:

Added a new example to the rn-tester, where we can notice that the image on the right is reloaded if rendered or re-rendered as the cache policy is set to reload. The image on the left has the cache policy set to default and won't be re-rendered as the image is already in the cache. See the video below:

https://github.com/user-attachments/assets/88bc1d2d-0239-4deb-bcde-fe0ce521ff4d

Also tested on both old and new architecture.

mateoguzmana avatar Oct 23 '24 22:10 mateoguzmana