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:
source share