Can NSURLCache be specified for a specific UIWebView or NSURLConnection?

Can I specify some other NSURLCache in some way? My application deals with potentially sensitive information. I would like to keep multiple caches so that I can flush the private cache more often than the standard sharedCache.

I saw the [NSURLCache setSharedCache] method, but I am wondering if there is a way to set the [NSURLCache setSharedCache] or request a request.

Any input / feedback / discussion would be helpful. Thanks.

+4
source share
1 answer

There is a callback in NSURLConnectionDataDelegate that can help.

 - (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse; 

connection: willCacheResponse: gives the delegate the opportunity to check and modify NSCachedURLResponse, which will be cached by the bootloader if caching is enabled for the source NSURLRequest. Returning nil from this delegate will prevent resource caching.

Please note that the -data method of the cached response can return a copy of the true data that is self-implemented in memory and should not be used as an alternative to receiving and accumulating data through the connection: didReceiveData:

+1
source

All Articles