How to check network response is from Cache or Server in Alamofire request?

Viewed 1041

I am making network calls using Alamofire and caching response in iOS app.

response is caching, but I am not able to check whether received response is from Cache or Server?

How to check the same?

1 Answers

You can check if there is any cached data for a request is available or not using.

if let cacheData = URLCache.shared.cachedResponse(for: request) {

  // Already cached
}
Related