3

A previous question looked like it was asking a similar question but it wasn't answered.

Can I just change the images on the server, keeping the same URL, and rely on HTTP 304 and other mechanisms to reload the new version of the image even if they exist in the cache?

My first thought was that any change to an image would have to also change the name of the image to force a refresh.

Possible workaround - suppose I have a bunch of images that share a common URL root, such as https://server/path/A/image.png and https://server/path/B/anotherimage.png. Can I remove all images from one path without invalidating the other - for instance, when something referring to a chunk of information represented by the contents of https://server/path/A is changed I could reload every image associated with it but not those in other folders?

My use of Kingfisher is basic so far using the extension on UIImageView:

myImage.kf.setImage(with: imageURL)

Adam Eberbach
  • 12,309
  • 6
  • 62
  • 114

2 Answers2

5

May this will help you Skip cache searching, force downloading image again

imageView.kf.setImage(with: url, options: [.forceRefresh])
Sujit Nachan
  • 204
  • 1
  • 8
  • Not really. If the app has to force a cache refresh then that implies the app knows when the image cached ceases being valid. It doesn't. The image stored can change in the download location and the app has no clue until HTTP status should cause the cache to refresh it. – Adam Eberbach Oct 22 '18 at 23:15
1

For Kingfisher first, assign a default placeholder and forceRefresh

let tempImage = UIImage(named: "user_placeholder")
 self.avatarImageView.kf.indicatorType = .activity
 self.avatarImageView.kf.setImage(with: avatarURL,placeholder: tempImage,options: [.forceRefresh])
Darshan
  • 2,272
  • 3
  • 31
  • 43