i am using glide for showing loading images, and in my app image will be changed frequently, is there any option for clear cache when new image or image will be edited otherwise load old one?
Asked
Active
Viewed 221 times
0
-
Is that possible for you share your code / demo ? – Maulik Sakhida Nov 19 '19 at 10:46
-
If the url is also getting changed then the cached image wont be loaded as files are cached against url & If it is the image file only that is being changed and not the url, then what you can do is make two requests, one with caching enabled and one with caching disabled – Ramees Thattarath Nov 19 '19 at 11:43
2 Answers
0
try this:
whenever image changes the cache will remove
Glide.with(YourActivity.this)
.load(Uri.parse(image_url))
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.into(mImage);
refer this link hope it will help you to resolve this issue

MurugananthamS
- 2,395
- 4
- 20
- 49
0
I have used the below code to achieve the same that you have mentioned in the description above.
fun ImageView.loadUrl(url: String) {
var requestOptions = RequestOptions()
requestOptions.signature(ObjectKey(System.currentTimeMillis()))
Glide.with(this).load(url).apply(requestOptions).into(this)
}
It's just an extension for the imageview
and you need to use below way wherever you want this in your app.
imageView.loadUrl(url)

Suraj Bahadur
- 3,730
- 3
- 27
- 55
-
Never use System.currentTimeMillis() as signature. Since this value is always changing, it forces Glide to download again the image every time. It is equivalent to not caching anything. – Ezequiel Adrian May 06 '23 at 12:37