HTTP status code 103 “Early Hints” is an informational status code that allows the server to send some hint information to the client before the complete response is ready, while it has already understood and is processing the client’s request. This status code is typically used in conjunction with the Link header to allow browsers to start preloading resources, such as stylesheets and script files, while the server is still preparing the final response.
The benefit of using 103 Early Hints is that it can help reduce page load times by allowing the browser to begin loading critical sub-resources while waiting for the server to complete its response. This can reduce perceived latency for users and enhance the overall user experience.
Scenarios for Using 103 Status Code:
- When the server requires time to generate a response, such as executing database queries or performing complex calculations.
- When the key resources for a page (like CSS and JS files) have been determined and can be preloaded to accelerate page rendering.
Considerations When Using 103 Early Hints:
- Ensure that the hinted resources are stable and not frequently changing to avoid resource mismatches.
- For backward compatibility, it is recommended to send 103 Early Hints responses only on HTTP/2 or higher versions, unless it is known that the client can correctly handle this status code.
- Early hints should contain clear hint information so that the client can take appropriate actions.
For example, the server might send the following response headers to use Early Hints:
103 Early Hints
Link: </css/style.css>; rel=preload; as=style
Link: </js/app.js>; rel=preload; as=script
This informs the browser to start loading the specified CSS and JS files while waiting for the complete page response.