X3 does not "cache domain names". But X3 pages will get cached with responses based on the domain they were accessed from. If you have multiple domains that access the same website, that means you can have cached pages with responses matching different website domains. This is why it's recommended to consolidate and redirect your efforts to a single domain, as noted in this post:
viewtopic.php?f=62&t=9080
If you have now setup 301 redirects towards a single primary domain, and it's working properly (also across https and www/non-www), all future cache will get created from the single primary domain. To force cache refresh, you could click "SAVE" in panel settings, which will cause all page cache to invalidate, and new cache will get created from the domain they are accessed from ... After all, X3 can't create cache from domains it doesn't know about and if nothing is requested from those domains. These "page cache" fragments include XML sitemap and feed output, so they will also get recreated from the domain they were requested from (until cache again is invalidated).
Matt wrote:I'd expect the sitemap and the RSS/Atom links to always reflect the current domain the site was called from, and not some other domain name X3 seems to have seen sometime in the past.
It caches from the first domain that requests a NEW output (after cache was invalidated, because something changed). If you want dynamic output based on different domains, it would mean we couldn't really use cache. Besides, I don't see why this would be useful ... There is no benefit for you or anyone else that you have one and the same website scattered around multiple domains ... Or sitemaps that tell Google that one single page exists randomly on multiple domains.
I don't see any bug here. If you have setup all redirects correctly, and invalidated cache, all pages will get created and cached from the single primary domain.
Matt wrote:But even deleting the page cache didn't change anything.
You mean from the panel? Any CHANGE from X3 panel, will automatically cause pages to get refreshed from the next domain they get requested from ... Because making changes in the X3 panel, is when your X3 website changes. The only other reason why pages would remain stale, is if the redirects are not working properly, or you have some network mechanism or CDN (like Cloudflare) that is caching page output.
Matt wrote:Finally I set the "Force URL" parameter to my main domain and those links were correct again.
This can be used, but it doesn't have any effect if you already have working redirects, because that's basically what it does. The only difference is that it can only make redirects to requests that X3 controls (basically your X3 website) ... It can't redirect requests made to other apps or resources, unlike if you setup real redirect in .htaccess or server config.
If you want me to diagnose this further, I would need to see real links.