How to disable caching from NSURLSessionTask

后端 未结 7 605
终归单人心
终归单人心 2020-12-04 23:24

In my iOS app, I am using NSURLSessionTask to download json data to my app. I discovered that when I call the url directly from the browser, I get an up to date

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-04 23:56

    The below code worked for me, the catch is setting URLCache to nil.

     NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
        config.requestCachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
        config.URLCache = nil;
    

提交回复
热议问题