65

since I updated Xcode to Version 4.5 and started building for iOS 6 log messages like this keep appearing:

ADDRESPONSE - ADDING TO MEMORY ONLY

I never asked for that (at least not consciously).

What do I need to do to stop these messages ? And what is their origin ?

Till
  • 27,559
  • 13
  • 88
  • 122
Jörg Kirchhof
  • 1,530
  • 1
  • 9
  • 19
  • FWIW I’m seeing the same thing. – bdesham Sep 22 '12 at 21:31
  • 2
    This is something new. In my code it seems to concern request-caching and a UIWebView. `ADDRESPONSE - ADDING TO MEMORY ONLY: http://domain.com/`. I'm using `[NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30];` – Gustav Sep 24 '12 at 01:17
  • 1
    I can also report that this happens from time to time when using methods like [NSData dataWithContentsOfURL:... – Olof_t Sep 27 '12 at 10:01

2 Answers2

68

I'm experiencing the same issue, the message is being issued from the CFNetwork framework, this happens both on device and in the iOS simulator. Specifically running strings on CFNetwork shows:

ADDRESPONSE - not adding TO DISK OR MEMORY: %@ ADDRESPONSE - ADDING TO MEMORY ONLY: %@

My guess is it is being issued by CFCachedURLResponse method.

An update - with further investigation my problem is caused by the following:

NSURLCache *cache = [[NSURLCache alloc] initWithMemoryCapacity: memoryCapacity diskCapacity: discCapacity diskPath:[SDURLCache defaultCachePath]];
[NSURCache setSharedCache:cache];

Where memoryCapacity == 0. Setting this to some realistic value like 10MB stopped the messages from being issued and appeared to retrieve objects from the cache as I would expect.

Unfortunately or otherwise depending on your perspective NSURLRequest etc behaviour changed with iOS 5. NSURLRequestCachePolicy is now acted upon, meaning you will need to check which iOS version your app is running on and adjust your caching behaviour accordingly.

  • 3
    a good answer … i've upvoted it … helpful … however, in my case, i'm getting this message even though i'm using NSURLCacheStorageAllowedInMemoryOnly on my URL request. uh, so i want this behavior, why should there be a log message that confirms it … ? (rhetorical) – john.k.doe Sep 28 '12 at 17:04
  • In my case I never change any of the caching parameters, and only use the default NSURLRequestUseProtocolCachePolicy. I still get the same log message for each HTTP request. – fishinear Nov 01 '12 at 11:27
  • I'd suggest if you detect you are running on iOS6 you explicitly set the memory and disk cache parameters before your first use of the URL loading system. That way you know what resources your application is using/has requested. – Shane MacPhillamy Nov 02 '12 at 23:45
  • 20
    i don't understand why you have to "REMOVE" this. It's not a warning or error. Check your log. It is simply a Notification. iOS notify you that the resource at the address indicated in the message was cached and so, the bytes corresponding are copied directly into memory. It is called cache. – valvoline Feb 19 '13 at 01:21
  • Interestingly, I am not using any URLs or networking in my app, and am also getting this log message for the first time on an app that never used to get it, even with iOS 6 – johnbakers Mar 21 '13 at 07:17
  • If you really want to get rid of this log message, you can clear your cookies and data in the safari settings. That removed it for me. – Andrew Jun 07 '13 at 16:11
0

I have same issue as like you. I don't know but I did fixed it by using following formation in viewDidLoad method.

-(void) viewDidLoad
{
  // First write my code of UI Creation.
  // Then I call 

  [super viewDidLoad]; //add [super viewDidLoad] AFTER implementation, not before.
}

This is working well for me, hope this is also work for you.

iPatel
  • 46,010
  • 16
  • 115
  • 137