removeAllCachedResponses can not clear sharedURLCache?

| | August 4, 2015

I made a button to clear my cache:

    [[NSURLCache sharedURLCache]removeAllCachedResponses];

after this being done, I check the size of sharedURLCache:

NSInteger sizeInteger = [[NSURLCache sharedURLCache] currentDiskUsage];
float sizeInMB = sizeInteger / (1024.0f * 1024.0f);

the sizeInMB is 0.17, sometimes 0.13. Never 0.0. Why the removeAllCachedResponses doesn’t make the sharedURLCache to ZERO ?

ps: in AppDelegate.m didFinishLaunchingWithOptions:

NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:2 * 1024 * 1024
                                                                    diskCapacity:20 * 1024 * 1024
                                                                        diskPath:nil];

    [NSURLCache setSharedURLCache:sharedCache];

Leave a Reply