1

Our current system works like this. An object has a timestamp to indicate an image has been updated for the apps. This timestamp will be updated when the image is uploaded to the storage. The old image will be replaced by the new image.

But our iOS developer (Frank) has a problem, he is using SDWebImage to load the image in his cell. But when he uses the same path and the image timestamp in the object changes SDWebImage does not reload the image. Because it caches the image with the URL.

How can this be solved?

Stan van Heumen
  • 2,236
  • 2
  • 11
  • 20
  • Have you read this? http://stackoverflow.com/a/16277427/6203030 I looking for an answer for not clearing all cache. Or this one: http://stackoverflow.com/questions/8751782/how-to-use-sdwebimage-without-any-cache-for-one-instance And could you share the code which you are trying to accomplish? – Aitor Pagán Apr 03 '17 at 14:52

2 Answers2

0

You should remove the cached image. SDImageCache makes you to manage cached data of SDWebImage, and it has properties that can remove cached images.

Of course, you could all cached images or only one image with the url. My code in my projects is below.

SDImageCache* cache = [SDImageCache sharedImageCache];

[cache removeImageForKey:"the cache Url of the image which you want to remove" fromDisk:YES withCompletion:nil];

It works for me, and it won't let you remove all cached data. Hope it helps

ShineMan
  • 354
  • 5
  • 14
0

I have the exact same issue.

If you're using the database for referencing your storage objects then the below may work for you.

Whilst the name of your file doesn't change when the image does, the separate download link does (found in the metadata on Firebase console). Instead of using the standard Firebase storage method, use the unique download url with SDImageCache. Everytime the image is updated, this url will refresh and SDImageCache will recognize it as a new one!

imageToSet.sd_setImage(with: URL(string: imageUrl), 
placeholderImage: "Profile-Placeholder")
alextudge
  • 113
  • 6