1

AFHTTPRequestOperationManager always give the cache response by default or otherwise.

Does anybody know How to solve the issue?

Ganesh
  • 101
  • 1
  • 11
  • Check this post - http://stackoverflow.com/questions/9968050/how-to-disable-afnetworking-cache –  Jan 04 '16 at 06:28

2 Answers2

1

You can use:

[[[AFHTTPRequestOperationManager manager] requestSerializer] setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
Satish Azad
  • 2,302
  • 1
  • 16
  • 35
  • Thanks @Satish Azad. I used this But it is not working at all. Giving the same old response. – Ganesh Jan 04 '16 at 06:59
  • First clear the cache memory before implementing this and the execute new implemented code. – Satish Azad Jan 04 '16 at 07:00
  • what I am doing is. I am testing this webservice with two account. When I am using different accounts I'm supposed to get different responses. But this is not happening here. – Ganesh Jan 04 '16 at 07:08
  • AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.securityPolicy.allowInvalidCertificates = YES; [manager.requestSerializer setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; – Ganesh Jan 04 '16 at 07:08
  • I think thats fine. Did you checked after clearing Local Cache data? – Satish Azad Jan 04 '16 at 07:10
  • I even tried to forcefully ignore the cache using following lines. – Ganesh Jan 04 '16 at 07:10
  • NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil]; [NSURLCache setSharedURLCache:sharedCache]; – Ganesh Jan 04 '16 at 07:10
0

Just try this. [manager.requestSerializer setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];

酷酷的哀殿
  • 1,021
  • 6
  • 18
  • Thanks @孙博弘. I used this But it is not working at all. Giving the same old response. – Ganesh Jan 04 '16 at 06:59
  • How do you know the response is old response?Do you have use the Charles to see what happed? – 酷酷的哀殿 Jan 04 '16 at 07:10
  • Actually these are dummy accounts for testing. I know the response that is coming. The same is implemented for android and it is working fine. I am using AFHTTPRequestOperationManager but i am getting old response only after successful login. – Ganesh Jan 04 '16 at 07:15
  • Have you check the request body?Maybe you have the wrong request. – 酷酷的哀殿 Jan 04 '16 at 07:19
  • Yes checked. It is perfectly fine. If I remove the build and recompile it and test with different account then it works fine. – Ganesh Jan 04 '16 at 07:21