Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
408 views
in Technique[技术] by (71.8m points)

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...