android - 关于glide+recyclerview默认读取缓存
PHPz
PHPz 2017-04-17 17:44:58
0
2
487

如上问题,关于glide+recyclerview默认读取缓存,导致刷新时,即使对方更新了头像但是url还是原来url,就会去默认读取缓存,设置signature后,问题是解决了,但接着每次都会去刷新头像,缓存的意义就没有了,求解!

 Glide.with(context)
            .load(uri)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .crossFade()
            .signature(new StringSignature(UUID.randomUUID().toString()))
            .into(view);
PHPz
PHPz

学习是最好的投资!

reply all(2)
Ty80

If you want to get a new avatar only after the user updates the image, the key issue is to let the app know that the image cache corresponding to the url is invalid.
So you should start with the relevant parameters cached in the header of the response returned by the url.

If you are using an interface provided by a third party, you have no choice but to choose whether to update the image every time without caching, or to compromise and update it every once in a while.
If you can modify the interface for obtaining avatars, It is recommended that the person who writes the interface add cache information to invalidate the client cache when updating the avatar.

左手右手慢动作

Glide decides to load the cache or re-request based on the URL. If your URL remains unchanged but the image content changes quickly, it is best to disable the cache

.skipMemoryCache( true )
.diskCacheStrategy( DiskCacheStrategy.NONE )
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template