1

I know NSURLSession uses NSURLCache to cache HTTP responses, so if I use NSCache to cache image downloads due to its own advantages, am I having two copies in memory for each cache, and thus being wasteful?

If so, how do I stop NSURLSession from caching in memory automatically? (I still want the persistent store caching though.)

Doug Smith
  • 29,668
  • 57
  • 204
  • 388

1 Answers1

0

You can create custom NSURLCache object with zero or just few bytes of memory. And than set it as shared cache to prevent memory usage.

NSURLCache * cache = [[NSURLCache alloc]initWithMemoryCapacity:1024 diskCapacity:1024*1024 diskPath:nil];
[NSURLCache setSharedURLCache:cache];

Apple Docs

sage444
  • 5,661
  • 4
  • 33
  • 60