Permalink
Browse files

Disable duplicate disk cache prevention with SDWebImageRefreshCached …

…to handle 302 caching correctly

See #326 (comment) for more info
  • Loading branch information...
1 parent 9a29af4 commit 8cfd26f78b30de78726291de367fc52907b848ca @rs committed Mar 12, 2013
Showing with 3 additions and 9 deletions.
  1. +3 −2 Examples/SDWebImage Demo/MasterViewController.m
  2. +0 −7 SDWebImage/SDWebImageManager.m
View
5 Examples/SDWebImage Demo/MasterViewController.m
@@ -30,7 +30,7 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
target:self
action:@selector(flushCache)];
_objects = [NSArray arrayWithObjects:
- @"http://static2.dmcdn.net/static/video/451/838/44838154:jpeg_preview_small.jpg?20120509163826",
+ @"https://graph.facebook.com/olivier.poitrey/picture?height=200&width=200",
@"http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.jpg?20120509154705",
@"http://static2.dmcdn.net/static/video/629/228/44822926:jpeg_preview_small.jpg?20120509181018",
@"http://static2.dmcdn.net/static/video/116/367/44763611:jpeg_preview_small.jpg?20120509101749",
@@ -371,8 +371,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}
cell.textLabel.text = [NSString stringWithFormat:@"Image #%d", indexPath.row];
+ cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
[cell.imageView setImageWithURL:[NSURL URLWithString:[_objects objectAtIndex:indexPath.row]]
- placeholderImage:[UIImage imageNamed:@"placeholder"]];
+ placeholderImage:[UIImage imageNamed:@"placeholder"] options:indexPath.row == 0 ? SDWebImageRefreshCached : 0];
return cell;
}
View
7 SDWebImage/SDWebImageManager.m
@@ -137,13 +137,6 @@ - (NSString *)cacheKeyForURL:(NSURL *)url
{
BOOL cacheOnDisk = !(options & SDWebImageCacheMemoryOnly);
- if (options & SDWebImageRefreshCached)
- {
- // When SDWebImageRefreshCached option is enabled, the disk caching relies on NSURLCache one.
- // We thus fork SDWebImage cache to be disabled so we don't duplicate the required storage space for nothing.
- cacheOnDisk = NO;
- }
-
if (options & SDWebImageRefreshCached && image && !downloadedImage)
{
// Image refresh hit the NSURLCache cache, do not call the completion block

0 comments on commit 8cfd26f

Please sign in to comment.