I am working with a server that responds with the following headers:
Cache-Control: no-cache
last-modified: Mon, 17 Dec 2018 14:47:19 GMT
The following code:
let myTask = URLSession.shared.dataTask(request: myRequest, completionHandler: { ... })
myTask.resume()
correctly sends the If-Modified-Since header.
But when I do:
URLCache.shared.cachedResponse(for: myRequest)
I get a nil result, whereas with:
URLCache.shared.getCachedResponse(for: myTask, completionHandler: { ... })
I get a non-nil result in the completionHandler.
I would have expected both giving me similar results. Can someone explains that to me?
This checks my local cache response.
Also you can check the definition as per apple.