How to update image in cache when image changed on server with SDWebImage

前端 未结 6 1561
感动是毒
感动是毒 2020-12-16 12:48

I am using SDWebImage library to download images from server. https://github.com/rs/SDWebImage

SDWebImage not able update the cached image when image updated on serv

6条回答
  •  一向
    一向 (楼主)
    2020-12-16 12:55

    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.

    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];
    

    See more here

提交回复
热议问题