From 439c01527fb4c0fc1e8effcac0979715904c2bd1 Mon Sep 17 00:00:00 2001 From: Olivier Poitrey Date: Wed, 17 Mar 2010 12:42:29 +0100 Subject: [PATCH] Ensure URL caching is disabled in order to prevent from duplicate caching --- SDWebImageDownloader.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SDWebImageDownloader.m b/SDWebImageDownloader.m index e7d9e3ff..3fa1f462 100644 --- a/SDWebImageDownloader.m +++ b/SDWebImageDownloader.m @@ -47,11 +47,13 @@ static NSOperationQueue *downloadQueue; downloadQueue.maxConcurrentOperationCount = max; } -- (void)main +- (void)main { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]]; + // In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests + NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:5]; + UIImage *image = [UIImage imageWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:NULL]]; if (!self.isCancelled && [delegate respondsToSelector:@selector(imageDownloader:didFinishWithImage:)]) {