Search code examples
iossdwebimage

Save image to cache with URL in SDWebImage


I meet a demand that my app will upload some image to web service, and later my App has big chance to download it with URL by SDWebImage when my App refreshes UI with after fetching data from web service.
Since the image is uploaded by my app, so I think I should save it in cache of SDWebImage with a URL, so later when I use SDWebImage to load the image by the url, it will pick it up from cache, better for performance.


Solution

  • If you're getting images from your app (and server) then don't store images to cache else it will become complex to handle. In good case, you should always fetch images from the server using SDWebImage if its already in cache, it will load directly from there. No need to handle an extra case. While loading new images from server, you can always show a place holder to make your UI better.