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

Shubham picture Shubham · Feb 18, 2015 · Viewed 16.6k times · Source

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 server with the same url.

Answer

Edgar picture Edgar · Feb 18, 2015

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