0

I'm loading images to my view with the following code:

private func setUpImage(imageFile: String, cell: ShowCollectionViewCell) {
    cell.showImageView.sd_imageIndicator = SDWebImageActivityIndicator.gray
    cell.showImageView.sd_setImage(with: URL(string: imageFile), placeholderImage: nil, options: .refreshCached)
}

The problem is, if we replace an image in our server, the image is never refreshed in the app, even if the user closes the app and relaunches it. Only a fresh install gets the new image.

Can SDWebImage detect if the image has changed remotely before using the cached version?

I'm using the latest version of SDWebImage with Swift 4.2 and XCode 11.1.

cesarcarlos
  • 1,271
  • 1
  • 13
  • 33

2 Answers2

0

I've search in StackOverflow and I found that.

In here

import SDWebImage

@IBAction func clearCache(sender: UIButton) {
    SDImageCache.sharedImageCache().clearMemory()
    SDImageCache.sharedImageCache().clearDisk()
}

As mentioned @guidev you try with cache reset.

This documentation can be old but I am sure you can make it work.

eemrah
  • 1,603
  • 3
  • 19
  • 37
0

The cache is based on the URL so you need to change the url name if you want the image to be redownloaded. Consider appending something like the last modified date to the url. alternatively send a push when the image updates and then manually evict the url from the cache with removeImageForKey.

Josh Homann
  • 15,933
  • 3
  • 30
  • 33