I’m developing an app which allows users to change their profile picture. On the home page, the image source URL for the user’s profile picture is set upon navigating onto the page and the source URL is simply the user’s unique ID ending with “.jpg”. When users update their profile picture, the old profile picture is overwritten and replaced with the new profile picture.
The problem arises when I try to refresh the page and show the new profile picture. On iOS, navigating away and back to the page after changing the profile picture will cause the new profile picture to appear. However, repeating the same steps on Android will not change the profile picture; instead, the old profile picture will persist. From this, I have two questions:
Does Android cache image sources from URLs? My theory is that Android isn’t “grabbing” the new image because the two images share the same source URL, so it uses a cached image source instead of the updated source. I saw this article which says that “To prevent that scenario, in NativeScript 2.5.x and above using the src property in Android will internally load the Bitmap in Java.”, but wasn’t sure if this applied to my issue.
How can I solve this issue? Assuming that my theory is correct (Android isn’t “grabbing” the new image because the two images share the same source URL), my current idea is to add another unique string to the photo URL such that, instead of using the same URL for both the previous and updated image, Android will grab the image source for the updated image since they now have different source URLs. However, this would require me to change how I grab profile pictures throughout my app; is there a way to either disable or clear the supposed Android cache?
EDIT: I got around this by adding a randomly generated query string at the end of my image source URL, but if anyone can shed some light on why this happened in the first place, I’d really appreciate it.