1

Basically I have images changing on the web server constantly but the URLs never change.

I notice that Alamofire has an interesting way of caching and I looked through the documentation to see what can be used to clear it.

I've found

let _url = NSURL(string: url)
let URLRequest = NSURLRequest(URL: _url!)
imageDownloader.imageCache?.removeImageForRequest(URLRequest, withAdditionalIdentifier: nil)
imageDownloader.sessionManager.session.configuration.URLCache?.removeCachedResponseForRequest(URLRequest)

But I still find that the image used before is still showing up even though the image on the server has definitely changed.

The main thing I am doing within my TableViewCells to load the image is this....

cell.avatar.af_setImageWithURL(url!, placeholderImage: ....)

So my hunch is that there is some caching done that I am still not clearing.

1 Answers1

2

Although I will still check for answers-- I improvised and addressed the url changes in the backend.

In other words, every time the image changed on the webserver I changed the url to that image.

Thanks.

  • This is a nice work-around in some way. But what if your other viewcontrollers' imageview also need to be updated with the new image. You will have to pass the new url address or update the model. Here is another solution which is to clear the image in cache and disk. http://stackoverflow.com/questions/33467263/how-to-clear-alamofireimage-setimagewithurl-cache – code4latte Aug 11 '16 at 07:58