Fixed #1993 Load image with option `SDWebImageRefreshCached` get error

#1737 introduced an issue that is using NSURLRequestReturnCacheDataDontLoad for our cached images which makes us never download again, which is not ok when using `SDWebImageRefreshCached`.
Fixed by reverting to the original implementation here: `NSURLRequestUseProtocolCachePolicy` vs `NSURLRequestReloadIgnoringLocalCacheData` (when `SDWebImageRefreshCached` is set)
This commit is contained in:
Bogdan Poplauschi 2017-08-11 16:37:29 +03:00
parent 2f892f968f
commit ecdd0128ab
1 changed files with 4 additions and 10 deletions

View File

@ -166,16 +166,10 @@
}
// In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests if told otherwise
NSURLRequestCachePolicy cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
if (options & SDWebImageDownloaderUseNSURLCache) {
if (options & SDWebImageDownloaderIgnoreCachedResponse) {
cachePolicy = NSURLRequestReturnCacheDataDontLoad;
} else {
cachePolicy = NSURLRequestUseProtocolCachePolicy;
}
}
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:cachePolicy timeoutInterval:timeoutInterval];
NSURLRequestCachePolicy cachePolicy = options & SDWebImageDownloaderUseNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData;
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url
cachePolicy:cachePolicy
timeoutInterval:timeoutInterval];
request.HTTPShouldHandleCookies = (options & SDWebImageDownloaderHandleCookies);
request.HTTPShouldUsePipelining = YES;