Why is Itunes Lookup API returning old app version?

I have a use case where I am able to reproduce this.

  1. The app store has a new app 1.2.0 version recently available (<24 hours)
  2. I'm on version 1.1.0 and I am receiving 1.2.0 version from the itunes lookup API
  3. I update the app via app store
  4. I will reinstall 1.1.0 from xCode to my device
  5. I'm on version 1.1.0 and I am receiving the previous 1.1.0 version from the itunes lookup API

I noticed if I change the cache policy from reloadIgnoringLocalAndRemoteCacheData to reloadRevalidatingCacheData it will show 1.2.0 on step 5 but why is this the case?

    let iTunesURL = URL(string: "https://itunes.apple.com/lookup?bundleId=\(bundleId)")
     
    guard let url = iTunesURL else {
      return nil
    }
     
    let urlRequest = URLRequest(url: url, cachePolicy: .reloadRevalidatingCacheData)
    let (data, _) = try await URLSession.shared.data(for: urlRequest)

     

Actually, seems like changing the cache policy doesn't fix it. It is very inconsistent on when it will get the latest version.

Why is Itunes Lookup API returning old app version?
 
 
Q