Why does the server prefer to return an early status code when it receives a request before the connection is fully established?

📅 October 12, 2026 👁️ 23

The connection has not been fully established when the request was received, why does the server prefer to return an early status code, and the point of consideration is whether this request can be replayed.This scenario comes from the early data mechanism of TLS: the client and server have not completed the full handshake, and the client sends the content to ask first, so the server receives the request before the connection is fully established.In response to such a request, the server can handle it normally or reject it first, clearly expressing its reluctance to take the risk of being replayed using status code 425.Whether to take this risk depends on whether the saved waiting value is worth it, and also depends on whether the request itself will cause a problem if it is executed repeatedly.

What does the early data save?

Early data, also known as 0-RTT data, allows the client to send a request in the round trip where the handshake is not yet completed, and the connection is just starting, without having to wait for the TLS handshake to be completed as in the regular process.The time saved is a complete round trip wait: in the past, we had to shake hands first and then send a request, now the handshake and request are squeezed into the same round trip to push forward. By definition, the client has already interacted with the server, so it can reuse this familiarity to send data in advance;And in the early data, the client sending the request was not required to add the Early-Data header extra, the request could describe what it wanted to do as usual.

What risks do the saved round trips bring?

The saved waiting is not without cost. The early data could be sent ahead of time because it skipped some protection that was only completed in the full handshake, the request arrived at the server before the connection was fully confirmed for identity and freshness.This leaves room for replay: one party has the opportunity to intercept this prematurely sent request, and then resubmit it unchanged to the server, causing the same operation to be executed twice.For some requests, it does not matter if they are executed repeatedly, but for others, it is an accident. The size of the risk is not fixed at the protocol layer, but follows the type of request, and the subsequent choices are determined by it.

What does this status code express?

Status code 425 Too Early is a client error status code indicating that the server is unwilling to risk processing a potentially replayed request, preferring to reject the request first to avoid potential replay attacks.Observe the tone: This is not a connection error, nor is it a mistake in the request format, but rather the server is主动表态—I admit that I received this request that came from the early data, but now I am unwilling to execute it.The server returns control to the client, allowing it to either send it again after the handshake is completely finished or take a more secure path. An early status code is a protective posture of retreat rather than a record of failure.

Which requests are suitable to send in early data?

Since the risk is concentrated on repeated execution, whether the early data judgment criteria can be clarified is also clear: to see if executing the request in the same way will change the current situation. Requests that only read information and whose results do not change with the number of times executed can only return the same content when replayed, with limited cost, and are suitable for抢占early data a bit of starting speed. Once the request will change the server side status - such as placing an order, changing a password, and deduction of this kind of write operation - does not belong to the category suitable for sending in advance, and the server is more inclined to directly block it back.

Why do we need to treat idempotent and non-idempotent separately

To summarize the above judgment into a single statement, it is that idempotent and non-idempotent requests should be treated separately. Idempotent requests, when executed repeatedly, result in the same outcome, while non-idempotent requests, when executed repeatedly, result in repeated effects: one order becomes two, and one deduction becomes two deductions.Because of this boundary, even if it means making an extra trip and taking a little more starting time, it is not a global switch, but a boundary based on request type. The safe approach is to allow only the secure part of the early data, and reject the rest first.Cut off all requests after the handshake, unnecessarily losing the time saved; putting all into early data, also exposing dangerous write operations to replay. The mature configuration is to draw a clear line between the two types of requests.

How to make choices at this level for a service built with Go

To be specific in a project, taking AnQiCMS as an example, it is based on Go language and built using the Iris framework. In such deployments, the TLS and connection layer are usually handed over to the front-end Web server for processing, when the handshake is completed, whether early data is enabled, and which requests are allowed to pass before the connection is fully established are often decided by the front-end server and the gateway, and the program code rarely directly touches this part.Therefore, the trade-offs related to 425 are more reflected in the front-end configuration rather than in the business logic. For services written in Go language, it is important to clarify the idempotent boundaries, hand over the write operations that should not be processed in advance to the channel after the handshake is completed, and entrust the handshake and replay protection to the front-end layer for unified handling, which is more in line with the division of labor of this technology stack.

Common questions

What exactly is saved by early data

What is saved is the round-trip delay brought by the handshake. The conventional process requires completing the TLS handshake before sending a request, but early data allows the client to send the request as soon as the connection starts and the handshake is not yet completed. The client's previous interaction with the server is the premise for it to send in advance.

Why does the server choose to return an early status code instead of handling it normally

Because there is a possibility of the request being replayed. 425 indicates that the server is unwilling to risk processing a potentially replayed request and prefers to reject first. This refusal avoids duplicate effects for write operations that change the state; for read-only idempotent requests, the server is more likely to process them directly.

Do we need to add an Early-Data header specifically for requests in early data?

As defined, it is not necessary. In early data, the client sending the request is not required to include the Early-Data header, the request can be described normally according to its own semantics. Whether it will be blocked back by an early status code depends on whether the request is idempotent and whether the server is willing to take the risk of replay, rather than whether this header is added or not.

Related articles

When the content does not change, the server only returns a status code, and conditional requests rely on which identifier to judge.

The cache expiration does not mean that you need to download the entire content again. ETag is the identifier of a version of the resource, and a new value must be generated when the resource content changes; the client uses If-None-Match to return the old value during a revisit, and if the server compares it and finds it consistent, it will only return a status code without the body. This article talks about what this identifier represents, the difference between strong verification and weak verification, why the weak identifier can affect segmented requests, and how sites with frequently changing content can use it to reduce duplicate transmission.

2026-10-12

The browser will mark whether the request is from this site or an external site, and how the server can prevent cross-site requests based on this.

The browser adds several Sec-Fetch request headers that indicate the source relationship, which frontend scripts cannot change. The values distinguish between same-origin, same-site, cross-site, and no-origin, and the server decides whether to allow or deny based on these relationships, thereby providing a complementary defense against cross-site request forgery; these headers are only sent in requests from trusted addresses. This article discusses the meanings of the four values, the way to allow based on context, and what they each manage in round-level operation approval.

2026-10-12

After the user logs out, old data still remains in the browser, how to require the response header to be cleared.

When logging out, the cache and local storage left in the browser will not disappear automatically. The Clear-Site-Data response header is a clear signal for the client, which can clear cache, credentials, storage, and execution contexts item by item, and it only takes effect in encrypted connections: credentials are cleared for the entire registration domain, and storage is only cleared for the current source. The login status within the site is carried by JWT, and the local data at this client layer relies on it to complete the cleanup. It is especially worth adding on public devices.

2026-10-12

When embedding third-party videos on a page, what authorization is used for iframe's capability to pass through?

The page embeds third-party videos with two levels of restrictions: source domain names are allowed to pass based on the whitelist, and capabilities such as camera, location, and automatic playback are authorized in the minimum set item by item. In the update records of PbootCMS V3.2.18, the default source strategy for trusted video domains is retained, and the token whitelist is set for the allow attribute. This article explains why the embedded frame carries scripts and media capabilities at the same time, how to differentiate between precise domain and subdomain wildcard, and why the release and authorization should be configured separately.

2026-10-12

When your own image is directly referenced by other websites, which response header decides whether to allow or not.

When your own image is directly referenced by other websites, it is the resource party that decides whether to allow it, not the referencing party. The Cross-Origin-Resource-Policy response header is set by the referenced resource, indicating which sources can load it, with values divided into three levels: same-origin, same-site, and cross-origin. The default is to block cross-site requests without cors. This article discusses which level each tier allows, whether it is on the same end as the initiating party, and whether images and fonts should be released separately.

2026-10-12

The server defaults to writing the program version into the response header and error page. Should this level of fingerprint be removed?

Most web servers default to writing the program version into the Server response header and error pages, the Nginx server_tokens directive is set to on by default, after it is turned off, the two places no longer contain version information. Removing this fingerprint can reduce the convenience of version collision, but it only reduces information exposure and does not constitute a defense. This article discusses where the version number leaks out and what remains after it is turned off, as well as where to make changes at each layer for different deployment methods such as Baota and Docker.

2026-10-12

Would adjusting the page layout make it easier for the generative engine to refer to it, and the experiment provides two percentages?

A generative engine optimization study decomposes the content structure into three layers: document architecture, information blocks, and visual emphasis, and conducts experiments on six mainstream generative engines. The report shows a 17.3% increase in citation rate and a 18.5% increase in subjective quality, without changing the main theme content. This article explains what these two percentages refer to, why structural improvement does not equal content quality improvement, and its division of labor with automatic site generation such as llms.txt.

2026-10-12

Is the site description file for the large model meant for humans or for agents, the proposal has changed the statement.

This site description file, according to the current proposal, is to help agents use the website, while the early expression is to help the language model understand the web page, and the service object has expanded from the model to the agent. The file is a plain text list, and only one item is required in the specifications: a first-level title with a project or site name, the rest of the abstract sections, descriptive sections, and file lists grouped by secondary titles are optional. AnQiCMS supports automatic generation of site llms.txt and is different from the site map.

2026-10-12