Did iOS 8 break NSURLCache?

前端 未结 3 2014
粉色の甜心
粉色の甜心 2021-01-31 21:08

Long story short, I just updated to Xcode 6 to check how my app works on iOS 8. I noticed that it doesn\'t use the cache even though it should. I\'m using AFNetworking setting t

3条回答
  •  广开言路
    2021-01-31 22:07

    Both NSURLCache and NSURLSession are buggy. Even if you set NSURLRequestReturnCacheDataElseLoad for request, iOS may try to reload file from server. It happens for example when cached response has Vary header. Also please notice that method

    - (NSCachedURLResponse *)cachedResponseForRequest:(NSURLRequest *)request
    

    use User-Agent header from request to distinguish cached objects. It means iOS will store the same file twice, if you access it by NSURLSession and UIWebView, because User-Agent is different.

提交回复
热议问题