103 Early Hints
103 HTTP status code, an informational response that enables servers to send HTTP headers to clients ahead of the final HTTP response.
The HTTP 103 Early Hints status code is an informational response that enables servers to send HTTP headers to clients ahead of the final HTTP response.
It works in tandem with Link headers and grants the client an opportunity to prepare accordingly.
By providing links to external resources that might be required for further processing, the client can proactively load these resources, potentially reducing latency and improving the overall user experience.
When a server sends the HTTP 103 Early Hints status code, the client has the option to interpret the Link headers and pre-fetch the specified resources.
This is particularly useful when the server requires additional time to process the HTTP request before providing the final HTTP response. For instance, while the server is preparing the final response, the client can utilize the time to render images that will be needed later.
It is essential to note that the 103 Early Hints status code serves as a hint and doesn't guarantee specific outcomes. The client can act upon the suggested resources to enhance efficiency, but it's only after receiving the final HTTP status code that the client can fully trust the headers.
This lack of guarantee means that some additional Link headers may be required, or some early hints may end up being unnecessary, potentially resulting in a slower transaction time. Nevertheless, operating based on Early Hints is safe, as it won't change the server's state.
In this example, the client makes a request for the index.html file, and the server responds with three early hints, suggesting resources likely to be required. The requested file is not yet available in the response body, allowing the client to start loading the specified resources indicated by each Link directive.
After a short pause, the server sends the final 200 OK response along with the official Link directives and the index.html in the message body. Notably, there are differences between the early hints and the final resource list. The resources specified in the early hints, such as style.css, logo.svg, and instructions_simple.mp4, are fetched and processed by the client as anticipated.
However, the pro_badge.svg image specified in the final response was not mentioned in the early hints, leading the client to fetch it upon receiving the final response.
Additionally, the instructions_advanced.mp4 video listed in the final response differs from the early hint, resulting in an unnecessary early hint fetch operation by the client. The newly-specified video must be fetched and processed before fully rendering index.html, potentially increasing the loading time.
The 103 Early Hints HTTP status code provides servers with the ability to send early hints to clients about resources that might be required in advance of the final response. This can help clients optimize resource loading and reduce latency by fetching necessary resources proactively.
However, it's essential for clients to be aware that early hints are not guaranteed, and the final response may include additional resources or exclude some of the hinted ones, necessitating flexibility in handling the response.