NSURLCache does not clear stored responses in iOS8

前端 未结 3 715
轮回少年
轮回少年 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 03:06

    Whenever any API call is generated, That response is saved in the cache. You are able to find that folder in your documents directory, a folder with named cachedb is created which contains a list of responses. It can be a major concern related to security. With any third-party tool, someone can have access to that information.

    Below is the way I have solved this issue :

    NSURLCache *cache = [[NSURLCache alloc] initWithMemoryCapacity:0 * 1024 * 1024 diskCapacity:0 * 1024 * 1024 diskPath:nil]; [NSURLCache setSharedURLCache:cache];

    I have allocated 0 memory space to the cache. so no data will be stored in Cache memory.

提交回复
热议问题