Fix NSURLResponse not cached when `SDWebImageDownloaderEnableNSURLCache` is passed #326
This commit is contained in:
parent
5cd7c0db46
commit
f097ef7558
|
|
@ -119,7 +119,7 @@ static NSString *const kCompletedCallbackKey = @"completed";
|
|||
|
||||
[self addProgressCallback:progressBlock andCompletedBlock:completedBlock forURL:url createCallback:^
|
||||
{
|
||||
// In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests
|
||||
// In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests if told otherwise
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest.alloc initWithURL:url cachePolicy:(options & SDWebImageDownloaderEnableNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData) timeoutInterval:15];
|
||||
request.HTTPShouldHandleCookies = NO;
|
||||
request.HTTPShouldUsePipelining = YES;
|
||||
|
|
|
|||
|
|
@ -311,8 +311,15 @@
|
|||
|
||||
- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse
|
||||
{
|
||||
// Prevents caching of responses
|
||||
return nil;
|
||||
if (self.request.cachePolicy == NSURLRequestReloadIgnoringLocalCacheData)
|
||||
{
|
||||
// Prevents caching of responses
|
||||
return nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
return cachedResponse;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue