SDWebImage / SDWebImageSwiftUI

SwiftUI Image loading and Animation framework powered by SDWebImage
https://sdwebimage.github.io/SDWebImageSwiftUI
MIT License
2.14k stars 219 forks source link

Trying to cache an image #192

Open JKim0119 opened 3 years ago

JKim0119 commented 3 years ago

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!

cpisciotta commented 3 years ago

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

afern247 commented 1 year ago

+1

dreampiggy commented 1 year ago

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

Dave181295 commented 1 year ago

+1 , give us a real sample

dreampiggy commented 1 year ago

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 commented 1 year ago

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