How to reload image in Glide from the same url?

I use the Glide image downloader to download an image from a specific URL, now if I update the image to the same URL, Glide still shows the cached image in my image. How to reload image from the same URL?

+4
source share
5 answers

According to the GlidewikiCaching-and-Cache-Invalidation

1. StringSignatureYou can use StringSignature to mix at a modified file time

Files . You can use StringSignatureto mix at a modified time file.

Urls. URL- , , URL- URL-, StringSignature

Glide.with(yourFragment)
.load(url)
.signature(new StringSignature(String.valueOf(System.currentTimeMillis()))
.into(yourImageView);

, - ,

  1. diskCacheStrategy() DiskCacheStrategy.NONE

    Glide.with(Activity.this).load(URL).diskCacheStrategy(DiskCacheStrategy.NONE  ).skipMemoryCache() .into(ImageView);

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

+5

.diskCacheStrategy(DiskCacheStrategy.NONE)

Glide.with(context)
     .load(url)
     .apply(new RequestOptions().placeholder(R.drawable.placeholder).error(R.drawable.error).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true))
     .into(ImageView);
+1

, . diskCacheStrategy (DiskCacheStrategy.NONE) skipMemoryCache (true). .

Glide.with(Activity.this)
    .load(theImagePath)
    .diskCacheStrategy(DiskCacheStrategy.NONE)
    .skipMemoryCache(true)
    .into(myImageViewPhoto);
+1

In order to load the same URL, you must set true glide skipMemoryCache().

Glide.with(this).load(yourImagePath)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.into(imageView);
0
source

After a battle for several hours, I find a solution. You can mix in a datetime file by adding StringSignature. Therefore, when the file is downloaded, it will always use the latest version. Like this

Glide.with(this)
.load(image_url)
.signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
.into(imageview);

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

0
source

Source: https://habr.com/ru/post/1691034/


All Articles