Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Glide Cache does not persist when app is killed

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 ?

like image 985
Magnas Avatar asked Feb 10 '16 14:02

Magnas


People also ask

Does glide cache images by default?

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.

How do I turn off glide cache?

To skip the disk cache only, use DiskCacheStrategy. NONE : Glide. with(fragment) .

What is Glide cache?

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.


1 Answers

Glide.with(fragment)
  .load(url)
  .diskCacheStrategy(DiskCacheStrategy.ALL)
  .into(imageView);
like image 123
Chandan kushwaha Avatar answered Sep 19 '22 14:09

Chandan kushwaha