5

I'm writing an app which needs to load a lot of images from the internet (a manga reader). I need to cache some thumbnail images for offline use, any others should be cleared when app closed.

I read some about cache invalidation on Glide page, they said the best way is to change the content url, but how Glide know if it is a modified url of old content or a new one? I'm new to Glide here.

https://github.com/bumptech/glide/wiki/Caching-and-Cache-Invalidation

Thank in advance :)

tuanna
  • 767
  • 1
  • 6
  • 13

1 Answers1

0

You can use following to load image:

Glide.with(context)
    .signature(new StringSignature(yourVersionMetadata))
    .into(imageView)

Just change yourVersionMetadata when you load image and it will not load from cache if yourVersionMetadata is different.

Sufian
  • 6,405
  • 16
  • 66
  • 120
KasoGG
  • 1
  • Thank, i will try it :) . And i would like to know if the cache will be deleted? – tuanna Jul 25 '15 at 12:19
  • It seemed that the old version cache was not deleted. When I change the _versionMetadata_ to the old one, the image showed up immediately. So I guess it was not deleted. – KasoGG Jul 27 '15 at 03:46
  • If that is the case then this method may not work for me :) . I want the old cache to be deleted to free up storage. – tuanna Jul 27 '15 at 09:57