NSURLCache does not clear stored responses in iOS8

前端 未结 3 727
轮回少年
轮回少年 2020-12-10 02:20

Here is the sample function I call when i need to clear cache and make a new call to URL

- (void)clearDataFromNSURLCache:(NSString *)urlString
{
    NSURL *r         


        
3条回答
  •  情书的邮戳
    2020-12-10 02:58

    NSURLCache is broken on iOS 8.0.x - it never purges the cache at all, so it grows without limit. See http://blog.airsource.co.uk/2014/10/11/nsurlcache-ios8-broken/ for a detailed investigation. Cache purging is fixed in the 8.1 betas - but removeCachedResponseForRequest: is not.

    removeCachedResponsesSinceDate: does appear to work on iOS 8.0 - an API that was added for 8.0, but hasn't made it to the docs yet (it is in the API diffs). I am unclear what use it is to anyone - surely what you normally want to do is remove cached responses before a particular date.

    removeAllCachedResponses works as well - but that's a real sledgehammer solution.

提交回复
热议问题