48

We have universal links working for a long time now. Today I added a path to the AASA file (let's call it sub2). The path was not recognised by the app, even after reinstalling it.

When I debugged I noticed the file is being fetched by the applinks service, but the request is not entering our server. The service does get the old AASA file, so it seems like apple's CDN is caching this file.

Debugging:

  • AASA file is valid: tested with Branch Validator as well as the new URL in Apple's appsearch-validation-tool

    {
        "applinks": {
            "apps": [],
            "details": [
                {
                    "appID": "redacted",
                    "paths": [
                        "/main/*",
                        "/sub1/*",
                        "/sub2/*",
                        "/pagex-*"
                    ]
                }
            ]
        },
        "activitycontinuation": {
            "apps": [
                "redacted"
            ]
        }
    }
    
    Apple tool: tested https://redacteddomain/sub2/something
    Link to Application: Passed
    Universal true
    ...
    
  • File is not cached at our side/Cloudflare: above validators confirm this but to be sure I also purged the cache

  • Iphone console shows the AASA file is being fetched:

    Beginning data task AASA-64DCD3xx-xxxxx { domain: xx….xx, bytes: 0, route: cdn }

  • Created a sysdiagnose file on the Iphone, it show the AASA file is fetched at this very timestamp but the contents is the old content:

    Service:              applinks
    App ID:               (redacted)
    App Version:          2.3.4
    App PI:               <LSPersistentIdentifier 0x101579cc0> { v = 0, t = 0x8, u = 0x11c0, db = 49C449xx-xxxx, {length = 8, bytes = 0xc011000000000000} }
    Domain:               (redacted)
    Patterns:             {"/":"/main/*"}, {"/":"/sub1/*"}, {"/":"/pagex*"}
    User Approval:        unspecified
    Site/Fmwk Approval:   approved
    Flags:                
    Last Checked:         2021-07-13 18:45:00 +0000
    Next Check:           2021-07-18 18:36:18 +0000
    

Is Apple effectively caching the file, is this because we provided wrong cache headers? How to test their CDN, are these urls public or can I find them back in the logs? Is there a way to force a purge at their side?

UPDATE: Found out we can directly query the CDN using the url https://app-site-association.cdn-apple.com/a/v1/yourdomain.com

=> This request returns the OLD file, while the original file (as mentioned in the Apple-From header) is newer! According to the Age header the file is however only minutes old..

UPDATE2: The issue is finally resolved, I can only guess the CDN cache refreshed now. I've made sure our server now sends a Cache-Control: no-store header, it seems this makes the Apple CDN cache it for one hour (max-age: 3600) now but after that hour it is effectively refreshed.

Note that before the sudden solution, the CDN returned a file with age of only a few minutes and a max-age of 1800 so it is still very unclear to me why it was not serving the new content 40 hours after the server file was updated.

At least for people with similar issues in the future, the CDN url is a very good starting point to debug: https://app-site-association.cdn-apple.com/a/v1/yourdomain.com

S. Roose
  • 1,398
  • 1
  • 12
  • 27
  • 3
    https://developer.apple.com/videos/play/wwdc2020/10098/?time=879 ? – matt Jul 13 '21 at 20:25
  • 1
    thanks @matt that answers my first question. As the problem still persists, the other questions remain.. how long is this cached, how to check, prevent, update – S. Roose Jul 14 '21 at 14:21
  • Well did you switch to developer mode as the video says? – matt Jul 14 '21 at 18:25
  • No, as that would not solve the production issue, right? – S. Roose Jul 15 '21 at 06:58
  • Yeah I have no idea. Need to poke the cache somehow...? But do try it and see – matt Jul 15 '21 at 07:15
  • I am wondering whether I could get the IP range for the Apple CDN servers so that I can whitelist it when it tries to hit my test environment. any thoughts? – rfsk2010 Oct 28 '21 at 18:39
  • 8
    The CDN checks your server every 24h, the device checks the CDN every week. https://developer.apple.com/documentation/xcode/supporting-associated-domains – Lachezar Todorov Nov 03 '21 at 14:18
  • 2
    This URL: https://app-site-association.cdn-apple.com/a/v1/yourdomain.com does not seem to return anything - just blank screen. – Aleksandar Vacić Jan 25 '22 at 14:32
  • @AleksandarVacić you'll have to substitute yourdomain.com with your domain name – S. Roose Jan 26 '22 at 15:36
  • 1
    I figured that out :) but it still returned blank screen. But that actually means that CDN can't access the AASA file at the domain, so it's still a good test. In my case, site access was geo-restricted so once admins fixed that, the URL worked and returned the file. – Aleksandar Vacić Jan 28 '22 at 13:35

0 Answers0