使用SDWebImage在服务器上更改映像时如何更新缓存中的映像 [英] How to update image in cache when image changed on server with SDWebImage

查看:126
本文介绍了使用SDWebImage在服务器上更改映像时如何更新缓存中的映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SDWebImage库从服务器下载图像。
https://github.com/rs/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在服务器上更改映像时如何更新缓存中的映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆