Why do the `cf-ray` headers differ between requests and responses?

Why do the cf-ray headers differ between the incoming request and outgoing response? ie i have a simple worker:

addEventListener("fetch", event => {
  event.respondWith(new Response(event.request.headers.get('cf-ray')))

The body of this response is 6c1e75538d86f009 but its cf-ray header is 6c1e75538d86f009-EWR … ie, the outgoing header has the colo but the incoming header does not… is this a bug? FWIW the preview window in the worker edit console does not have this discrepancy (they both have the colo).

You can see it here: https://cf-ray.jed.workers.dev/

That is the data centre location at the end. In this case near Newark, NJ, US.

The question is why do the headers differ? Why does only the outbound one have the colo?

You can get the colo with another value from the request.

Not sure why they do it this way. Personally, I like not having it as I can put it in the logs or pass it along in subrequests without trimming the colo off. :man_shrugging: