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
SDWebImage: After adding .refreshCached as option, get is being called without request headers If-None-Match
and If-Modified-Since
. How to cache those as well from response http headers and send in request http headers?
#3589
Comments
Try https://sdwebimage.github.io/documentation/sdwebimage/sdwebimageoptions/refreshcached The HTTP E-Tag based is using NSURLSession implementation (So, the NSURLRequest's The default options will change cache policy to See more: #2904 |
Simply used
there's nothing like |
i hardcoded header in AppDelegate to check
and i'm getting 304 for this. @dreampiggy can you help me with this for all cached url data through library? |
If you add You'll may see twice callback during a single image loading. One from the URLSession and which may hit 304, one from our local cache check. |
By default, requests are not being sent with |
Additionally, if i want to override header for each image request, how to get response header including etag and last-modified from cache? |
Use |
Does SDWebImage store headers along with image data in cache? |
No. But you can customize. See that Which use Xattr for backend. |
There is one documentation, I've already added some details explain about some features. https://sdwebimage.github.io/documentation/sdwebimage/ The Read and Write the extended object and bind it to the image. Which can hold some extra metadata like Image's scale factor, URL rich link, date, etc.
The extended object should conforms to NSCoding, which we use `NSKeyedArchiver` and `NSKeyedUnarchiver` to archive it to data, and write to disk cache.
@note The disk cache preserve both of the data and extended data with the same cache key. For manual query, use the `SDDiskCache` protocol method `extendedDataForKey:` instead.
@note You can specify arbitrary object conforms to NSCoding (NSObject protocol here is used to support object using `NS_ROOT_CLASS`, which is not NSObject subclass). If you load image from disk cache, you should check the extended object class to avoid corrupted data.
@warning This object don't need to implements NSSecureCoding (but it's recommended), because we allows arbitrary class. |
Which means: Inside your Then the extended object will be written to disk cache via Xattr. For the same cache key. Next time you can use |
Thank you @dreampiggy |
Is it possible for this header to be internally included in upcoming updates of SDWebImage when adding refreshCached as an option? |
I don't know actually. And have no plan, since I'll not work on iOS SDK (espacially network part) and focus on some other scope like Compiler currently. The current We throw all the cache related logic into URLSession and Apple's SDK... If URLSession does not implements HTTP Cache control, or has bugs on some firmware version, it will broken. About Feature requestI guess you means that all the You're welcome to create implementation (actually this is a standalone feature, which don't need SDWebImage any code, you can create a pure Demo using URLSession for that 304 status code handling and using HTTP HEAD method. like https://developer.apple.com/forums/thread/50586) Maybe AFNetworking (Alamofire) has the similar demo ? See #2904 |
Issue Description and Steps
As per my understanding it must be adding http header and we'll get 304 (not modified in response).
The text was updated successfully, but these errors were encountered: