Invalidating the image cache for Glide.
- Dominant language
- Java
- Stars
- 35k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 8
Description
Hi Experts,
I have an issue that has been discussed quite extensively in the past on various forums - however, I haven't come across a discussion that describes my problem accurately. I was hoping to get some insights.
I use Glide (Android) to load images into image Views for items in the recycler View. The URLs of the images to be loaded into the list items of the recycler view are images assigned to contacts. Whenever the image corresponding to a contact changes, the URL remains the same. I have come across various methods using which the Glide cache may be invalidated such as:
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
OR
signature()
However, I seem to run into a peculiar problem. Certain times, many of the visible items of the recycler View all correspond to the same contact and by extension have the same image loaded. If, the image corresponding to the contact is changed, I cannot use any of the approaches highlighted above as it mostly results in only the image of the first occurrence of the contact changing, subsequent occurrences of the contact in the list of the visible items of the recycler view continue to load the older image - presumably because of the caching mechanism used by Glide. If I programmatically identify the specific contact whose image has been changed and use one of the two methods above, it does result in all instances of that contact loading the new image. However, the results in a visible Glitch wherein the placeholder image is loaded first followed by the new image - in short, the loading isn't quick and smooth.
I was wondering if there is a way to invalidate Glide's cache for a given URL globally or any other approach to solve my issue?
Would really appreciate any insights into this. Happy to provide a more detailed explanation if needed.
Contributor guide
Assessment
This issue has not been assessed yet.