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