I'm monitoring my web calls with Charles.
I have a GlideModule changing cache folder by overriding applyOption(...) like this :
@Override
public void applyOptions(Context context, GlideBuilder builder) {
builder.setDiskCache(
new InternalCacheDiskCacheFactory(context, "/media/", 1500000)
);
}
Then, I do my Glide images loads and the cache works just fine while I'm in the app. Here is an example :
Glide.with(this)
.load("http://www.wired.com/wp-content/uploads/2015/09/google-logo.jpg")
.into(mImageView);
Only the first call make a web call and then it use cache to retrieve it. However, if I kill the app then relaunch it, instead of continuing to use the cache, the app make a new web call. Isn't the cache supposed to be persistent inside the Internal storage ?
How does the Glide caching mechanism work? By default, Glide uses memory and disk caching to avoid unnecessary network calls, it checks into multiple layers of caches before initiating a new request call for an image.
To skip the disk cache only, use DiskCacheStrategy. NONE : Glide. with(fragment) .
Glide is a fast and efficient open source media management and image loading framework for Android that wraps media decoding, memory and disk caching, and resource pooling into a simple and easy to use interface.
Glide.with(fragment)
.load(url)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(imageView);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With