For Q&A and logging purposes, I need to know whether the response to an URLSessionDataTask comes from the URLCache or not.
I've read here and there that it was just a matter of comparing the cachedResponse before and after receiving the dataTask response. But it does not work as each call to URLCache.shared.cachedResponse(for: urlRequest) returns a new instance of CachedURLResponse (each one having another new instance of HTTPURLResponse).
Am I missing something? Is there another way to tell if the response comes from the cache?
I've read here and there that it was just a matter of comparing the cachedResponse before and after receiving the dataTask response. But it does not work as each call to URLCache.shared.cachedResponse(for: urlRequest) returns a new instance of CachedURLResponse (each one having another new instance of HTTPURLResponse).
Am I missing something? Is there another way to tell if the response comes from the cache?