It appears that URLSessionTaskMetrics
contains an array of transactionMetrics
and as per Apple's documentation, the transactionMetrics
contains "An array of metrics for each individual request-response transaction made during the execution of the task". My question is how does a URLSessionTask
have multiple requests? When we create a session task we create it with a single request object, so how is it possible for a single session task to contain an array of metrics? Shouldn't it be only one?
Asked
Active
Viewed 364 times
0

user2990765
- 387
- 2
- 3
- 16
1 Answers
0
there are two cases, I can get.
- the status code of response is 302.
- session task will request two times cause of the default value of request.cachePolicy is useProtocolCachePolicy. the first one fetches data from the local cache and the second fetch data from the net. However, if request.cachePolicy is reloadIgnoringLocalCacheData, its count will less 1.
try print transactionMetrics and compare the difference between them.

Zev003
- 85
- 4