If your (host is) using typical nginx config like this one on WP docs:
https://wordpress.org/documentation/article/nginx/#nginx-fastcgi_cache
Then you should be able to break caching with this:
if ($http_accept = "application/json") {
set $no_cache 1;
}
But nginx will cache different content based on the Accept header if you tell it to, e.g. as long as #WordPress #ActivityPub sends this with its responses, cache will differ by Accept header:
header('Vary: Accept');
https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_cache_valid