Clock conditioning is a process by which a web client estimates the difference between its own clock and that of a server in order to generate accurate timestamps for events.
The general idea is that the client clock, , differs from the server's clock, , by some fixed amount that doesn't significantly change over the course of their interactions. This fixed difference, is estimated by generating four timestamps associated with a request/response cycle.
The client notes the time it makes a fetch call to the server and the time it receives the response. The server adds a header to the response indicating the time it received the request and the time it sent the response. These four events happen in a fixed, causal order: client sends request, server receives request, server sends response, and client receives response.
If we number these events 1 through 4, the collected timestamps are , , , and -- events 1 and 4 are reported using the client's clock, and events 2 and 3 using the server's clock. If we let and , we have four times on the server's clock, but with an unknown value for .
Then , and similarly, . The values and are the transit times for the request and response messages, respectively, so .
On a typical network, and are of similar magnitude. More precisely, they can be modeled as a "best" transit time, plus some delay. By monitoring several request/response cycles and choosing the minimum values of and , they should both approach , so that , giving a high-quality estimate of the difference between the client's clock and the server's clock.