-
-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: SDWebImage appears to be using http GET method with .refreshcached instead of a HEAD method first #2904
Comments
This is not used for It use URLSession's This If you found that it always request GET method, maybe this total solution need to be re-written, or the URLSession have something new configuration which we can use. |
We are experiencing the exact same issue. We have a CollectionView at the bottom of our TableView cell that holds users account images (URLs from Facebook, Twitter, LinkedIn) Here is a video showing how it downloads as we scroll up and down.
Here is a video showing it not downloading as we scroll up and down.
Version of SDWebImage
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, please make sure it is up to date and if so, add a comment that this is still an issue to keep it open. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, please make sure it is up to date and if so, add a comment that this is still an issue to keep it open. Thank you for your contributions. |
Still open |
Need some more works for this. The worst, re-implements the HTTP Cache Control all details, like All of this is because of that |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, please make sure it is up to date and if so, add a comment that this is still an issue to keep it open. Thank you for your contributions. |
Still a issue, need more and feasibility solution for this task. Help wanted |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, please make sure it is up to date and if so, add a comment that this is still an issue to keep it open. Thank you for your contributions. |
Still an issue |
Even I am facing similar issue . do we have a workaround for it ? |
I think this is URLSession's bug or wrong behavior. When use It this does not work, we need rewrite this. But no one here provide a suitable MR or proposal for this problem :( |
@dreampiggy I was trying to set up requestPolicy for NSUrlCache but seems like it is not allowing to do that on shared downloader. maybe setting up the right policy on NSUrlCache can help ?? |
@surajrautela Use requestModifier: https://sdwebimage.github.io/SDWebImage/Classes/SDWebImageDownloader.html#/c:objc(cs)SDWebImageDownloader(py)requestModifier Change the NSURLRequest.cachePolicy |
I did that but it still didn't worked . However when I simply used NSUrlCache without using SDWebImage everything worked fine !. Seems like some issue with SDWebImageDownloader |
Sounds strange. You can debug the code. SDWebImage by default will override the cache policy to Howevr, you can still modify the cache policy by your own using Source code (where we set the cache policy) https://github.com/SDWebImage/SDWebImage/blob/master/SDWebImage/Core/SDWebImageDownloader.m#L270 Source code (where you can use request modifier) https://github.com/SDWebImage/SDWebImage/blob/master/SDWebImage/Core/SDWebImageDownloader.m#L286 |
@dreampiggy +1 for this issue, I'm running into this as well. The proposed workarounds do not work.
|
@dreampiggy I tried to debug the code . The policy is getting set correctly |
Already talked about this. |
any update on this ?? |
Any update? |
If NSURLSession does not do something magic, the last idea, is to Implments HTTP Cache control from stratch, drop NSURLSession's Although I still think this is something mistake between SDWebImage's usage, or Apple's documentation: https://developer.apple.com/documentation/foundation/nsurlrequestcachepolicy/nsurlrequestuseprotocolcachepolicy |
Maybe is that SDWebImage override this delegate method, cause the issues ? willCacheResponse: https://developer.apple.com/documentation/foundation/nsurlsessiondatadelegate/1411612-urlsession |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, please make sure it is up to date and if so, add a comment that this is still an issue to keep it open. Thank you for your contributions. |
Still an issue |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, please make sure it is up to date and if so, add a comment that this is still an issue to keep it open. Thank you for your contributions. |
Still an issue, can we reopen? @dreampiggy |
Platform Name iOS
Platform Version iOS 12+
SDWebImage Version 5.0.0
Integration Method Carthage/cocoapods
Xcode Version 11
Repro rate 100%
Repro with our demo prj unsure
Demo project link n/a
Issue Description and Steps
I filed a stack overflow question like the guide suggested but I didn't get a response.
Basically I'm wondering if I can configure
SDWebImage
to use a head method with.refreshCached
enabled to prevent unnecessary download bandwidth usage on our backend.Copy/pasted the text from the stack overflow question here:
I'm using
SDWebImage
for caching images in a Swift/iOS app, and we are using it in some places with.refreshCached
option enabled.We're using Amazon s3 for images which has support for the "Last-Modified" header on the request.
My understanding is that with
.refreshCached
enabledSDWebImage
should check the http header with a HEAD method to check to see the last modified date in the header, THEN if theLast-Modified
date has changed, it can perform a GET method on the URL to get the image data, saving bandwidth.However when I inspect the calls that the app is making (using
CocoaDebug
), I only see the GET methods in the log, meaning even when the image is cached we're still fetching all the image data.On subsequent views where the images are visible, I see that images load instantly, implying the cache is working, but I still see the full GET methods and no HEAD method in the log.
Does SDWebImage support this HEAD followed by GET flow or am I doing something wrong or otherwise misunderstanding?
The text was updated successfully, but these errors were encountered: