NSURLSession cache does not work in iOS8

I have the following code, it works fine in iOS7, but not in iOS8.In iOS8, the application always uses the cache, even I set NSURLRequestReloadIgnoringCacheData:

NSURL *url = [NSURL URLWithString:k_Chapter_URL]; NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:url]; NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration]; sessionConfig.requestCachePolicy = NSURLRequestReloadIgnoringCacheData; NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfig]; [[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { }] resume]; 

Do I have a similar situation?

+5
source share
1 answer

I think this is a bug in iOS 8. I was able to use resetWithCompletionHandler to make the cache clear.

 [session resetWithCompletionHandler:^{ [[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { }] resume]; }]; 
+1
source

Source: https://habr.com/ru/post/1200362/


All Articles