问题描述
我正在使用SDWebImage库从服务器下载图像。
I am using SDWebImage library to download images from server.https://github.com/rs/SDWebImage
SDWebImage在服务器上使用相同的URL更新图像时无法更新缓存的图像。
SDWebImage not able update the cached image when image updated on server with the same url.
推荐答案
SDWebImage
默认情况下进行一些缓存,因此如果图像发生变化,最好使用新的URL。因此,例如,如果您可以控制URL并且每次图像更改时都可以更改它,那么您可以这样做。
SDWebImage
does some caching by default, so it would be better to use a new URL if the image changes. So, for instance, if you have control over the URL and can change it every time the image has changed, you could do that.
如果不是这样,请尝试在选项
字段中使用 SDWebImageRefreshCached
以尊重HTTP缓存控制标头,如下所示:
If that's not the case, try using SDWebImageRefreshCached
in the options
field in order to respect HTTP cache control headers, like this:
[imageView setImageWithURL:[NSURL URLWithString:@"https://graph.facebook.com/olivier.poitrey/picture"]
placeholderImage:[UIImage imageNamed:@"avatar-placeholder.png"]
options:SDWebImageRefreshCached];
查看更多
这篇关于使用SDWebImage在服务器上更改映像时如何更新缓存中的映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!