Is it possible to clear cache of particular image with out loading the image to imageView. I know we can clear image like this:
Glide.with(context.getApplicationContext())
.load(imageurl)
.signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.placeholder(R.drawable.placeholder)
.into(imageItem);
but I would like to know is it possible to clear particular image url cache without loading the image to imageView object if so how do I do it?
You cannot remove individual images from the cache, even the code you quoted doesn't remove the old versions of imageurl from the cache directly: they stay in cache until the disk cache reaches the limit and LRU notices that it's the oldest so an eviction is in order.
Actually looking more into the above code it looks like that always downloads a new version AND saves the data into local cache, but that file will never be re-used because the signature always changes: .load(imageurl).diskCacheStrategy(NONE) would have the same result without wasting the user's precious disk space.
I am using 4.2.0 version of glide library but StringSignature class is missing from it. How can I avoid caching for a perticular URI from internal stoarge in this case.
I am using 4.2.0 version of glide library but StringSignature class is missing from it. How can I avoid caching for a perticular URI from internal stoarge in this case.
Most helpful comment
You cannot remove individual images from the cache, even the code you quoted doesn't remove the old versions of
imageurlfrom the cache directly: they stay in cache until the disk cache reaches the limit and LRU notices that it's the oldest so an eviction is in order.Actually looking more into the above code it looks like that always downloads a new version AND saves the data into local cache, but that file will never be re-used because the signature always changes:
.load(imageurl).diskCacheStrategy(NONE)would have the same result without wasting the user's precious disk space.