so i use glide everywhere in my app to upload the user's profile image via url. When the user changes their profile picture. I update the backend, so the url is updated. But, glide has cached the old image. How do i overwrite the previous cached image, so that when the user navigates through the app, he/she can see their profile picture change in all activities?
Asked
Active
Viewed 4,353 times
3
-
If the url changes glide downloads the image again – Diego Torres Milano Apr 27 '17 at 03:31
-
Please refer my answer here https://stackoverflow.com/questions/33443146/remove-image-from-cache-in-glide-library/33451376#33451376. This will help you out for sure. – Nitesh Kumar Sep 16 '17 at 13:00
2 Answers
6
RequestOptions requestOptions = new RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.NONE) // because file name is always same
.skipMemoryCache(true);
Glide.with(this)
.load(photoUrl)
.apply(requestOptions)
.into(profile_image);
In the latest versions we should use RequestOptions
RequestOptions Provides type independent options to customize loads with Glide in the latest versions of Glide.
Make a RequestOptions Object and use it when we are loading the image.

Vinay John
- 990
- 12
- 13
1
Call Glide.get(context).clearDiskCache()
on outside the UI thread. (also consider clearMemory()
too to prevent surprises after clearing disk cache)
Read Cache invalidation, because it's not otherwise possible to remove a single file from cache. If you explain your "Clear cache of an URL" use case we may be able to give a better suggestion.

Jigar Patel
- 1,550
- 2
- 13
- 29
-
here he not want to clear cache of gradle but want to remove cache of Glide from imageview to see updated image – Rajesh N Apr 27 '17 at 03:43
-
@Jigar Patel, i think you misinterpretted the question. Its when the user is actually using the app – TheQ Apr 27 '17 at 04:05
-