SDWebImageSwiftUI icon indicating copy to clipboard operation
SDWebImageSwiftUI copied to clipboard

Trying to cache an image

Open JKim0119 opened this issue 4 years ago • 6 comments

Hello, currently, I am using WebImage to load images from the web. I see in the readme that I can check out the wiki to learn how to use the "Reusable download, never request single URL twice". I'm having trouble understanding the wiki as its for Objective-C and Swift along with not really understanding where I'm supposed to be looking in the wiki to do the "Reusable download".

I was hoping to get some assistance on understanding how to cache the webimages/if they are just automatically cached anyways. Thank you!

JKim0119 avatar Jun 18 '21 18:06 JKim0119

+1. Any examples on how to properly cache image data using WebImage would be much appreciated.

cpisciotta avatar Jul 17 '21 07:07 cpisciotta

+1

afern247 avatar Sep 24 '22 06:09 afern247

Which means:

manager.load(url1, completion1)
manager.load(url1, completion2)
manager.load(url1, completion3)
manager.load(url1, completion4)
manager.load(url1, completion5)

// This actually only one URLSessionTask in whole memory, when it finished, it callback those 5 completion handlers one by one.

This is just a optimization, unlike you simply use URLSession.download(request) API from Apple, each of your call create a new URLSessionTask

dreampiggy avatar Sep 26 '22 06:09 dreampiggy

+1 , give us a real sample

Dave181295 avatar May 03 '23 09:05 Dave181295

Currently SDWebImage default SDWebImageDownloader, use URLSessionDataTask

which does not support automatic HTTP resumable download.

The wiki here means, If you request same URL from different callers in whole App, we never do actual two HTTP requests, instead we will merge them into one and just callback different callers one by one

dreampiggy avatar May 05 '23 06:05 dreampiggy

Seems the same as https://github.com/SDWebImage/SDWebImage/issues/867

dreampiggy avatar May 05 '23 06:05 dreampiggy