Return cache and then reload with async/await

Hi,

Is there any way to return cached URLSession response and then reload and return?

I want show cached response while load last version of API call, and if reload works fine, show the latest version of response and in case os failure, show cached response (if exists)

Thanks!

Is there any way to return cached URLSession response and then reload and return?

No, because that would require the request to return two responses, which isn’t something that the API can express.

However, you can achieve a similar effect by issuing an initial request with the .returnCacheDataDontLoad policy and then issuing a second request with the default policy.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Return cache and then reload with async/await
 
 
Q