如何用具有相同 url 的新图像缓存图像?

how to cache image with a new one which have the same url?

我有 listview 可以为很多用户加载图像,这个 listview 项目有一个用于用户个人资料图片的图像视图,如果用户更改了他的新图像,这里的问题将不会显示,因为最后一张个人资料图片被缓存并且将显示旧的,因为新旧图像具有相同的url: URL 例如: "https://xyz.s3.amazonaws.com/users/" + friend_id + "/photos/profile.jpg"

我用过Glide但我有同样的问题

这个问题是因为图片的缓存,Glide 会检查图片是否在缓存中可用,如果确实存在,glide 会加载它,否则它会加载新的图片。

要解决此问题,您需要像这样更改其缓存策略

Glide.with(mContext)
            .load((Integer) mDataset.get(position))
            .fitCenter()
            .diskCacheStrategy(DiskCacheStrategy.NONE) // this will prevent image to be cached and each time glide will load it from server
            .into(imageView);