For my use case - a REST API - I use AWS Global Accelerator, which provides static IP’s that makes requests incredibly fast, in terms of getting to the ALB/origin.
The original “performance enhancement” is just to hit an IP address that’s pre-known, without needing any DNS resolution at all. It’s significantly faster than anything else in terms of latency.
I’ve seen these threads - and they don’t resolve my issue:
I need to be able to fetch from an IP inside a worker, with or without a host header. Since the IP address is hidden inside a private worker - the world can’t see it anyway, in addition to the fact that it’s my trusted IP and it’s static. Adding it as an A record publicizes a private IP to the world.
@KentonVarda would resolve-over-ride work, or can I manually add a host header to make this work? I really need this, specifically for performance enhancement at the edge - since going to our origin via IP is significantly faster than any other method.
If you configure a DNS A (or AAAA) record mapping to your IP address, then you fetch() from that hostname, you should get the same effect as if you could specify the IP address raw. It should be just as fast – since the DNS is hosted by Cloudflare, the lookup will be instantaneous. It’s important to use an A record, not a CNAME. If you use a CNAME, then Cloudflare has to perform a DNS lookup for the hostname specified by the CNAME, which can take time. But with an A record, Cloudflare “just knows” the destination IP, so the lookup is “free”.