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

📅 October 12, 2026 👁️ 16

When the content does not change, the server can only return a status code, and the identification for conditional requests is determined by which indicator, the answer is the version identifier carried by the resource itself. When the browser first receives the resource, the response header will include an ETag, which is the response header that identifies a certain version of the resource;When the local cache expires, the browser does not hurry to redownload the entire content, but initiates a conditional request, using the If-None-Match request header to send back the old value obtained last time.The server compares the returned value with the current version, if they match, it returns 304, the response has no text, just tells the client: the version you have is still valid.

Is cache expiration the same as redownloading the entire content?

The working rhythm of caching is divided into two segments. During the fresh period, resources are directly read from the local copy, and there is no need to send a request; after expiration, resources are not immediately discarded, but first ask the server a question: Is this version still valid? This question is a conditional request. Without version identification, expiration can only be handled by redownloading all the content, even if not a single character has changed, it is obviously a waste to repeatedly transport the entire text or image; with identification, the judgment is degraded to comparing two strings, and when they match, there is no need to send the text even.

What does this identification represent?

The rule is only one: if the content of the resource at the same address changes, a new identifier must be generated; if the content does not change, the value remains unchanged. It does not describe what the content looks like, nor does it encode how long the content is, but it answers a question: Is this version the same as the last one you had.

It is a separate check from the way it is judged according to the last modification time. The time method compares when the file was last modified, and the version method compares whether it is the same version of content. The time granularity is coarse, and multiple changes within the same second may not be distinguishable; when the file is saved again but the content does not change, the update of the timestamp may cause misjudgment. The version identifier is more direct in judging content changes, and both can coexist. The client takes which condition header, and the server judges according to the corresponding logic.

How to compare during the follow-up visit

This is how the process is put together: The server provides an identifier value in the response, and the client stores the content along with it; after the cache expires, the client sends a new request and attaches the old value in If-None-Match; the server calculates the current version identifier and compares it. If consistent, it returns 304, and the client continues to use the local copy; if not consistent, it returns 200 and the complete new content, along with the new value, and the client replaces the old cache.

The key to generating an identifier is to distinguish between actually changing the content and just re-rendering it. If there is a fluctuating component in the input that changes with each request, such as the rendering time or random numbers, a new value will be calculated each time the response is given, and comparison will always fail, resulting in the verification degenerating into a full download each time, which is equivalent to no caching. Websites that mainly render content from databases are more likely to encounter this issue: the main text exists in the library, the accompanying resources are stable, and the identifier should only depend on the true input that represents the content. The computing input of each node in the cluster must also be consistent, otherwise the same version of the content will calculate different values, and the verification will mysteriously fail.

What is the difference between strong validation and weak validation

If a prefix W/ appears before the identifier value, it indicates that it is a weak validation identifier; if there is no prefix, it is a strong validation identifier. Weak identifiers are easy to generate, but are not suitable for byte-by-byte comparison: if both sides are equal, it can only mean that the content is roughly equivalent in terms of semantics, and cannot guarantee that each byte is the same.

The more practical impact is on segmented requests. Browsers sometimes use Range headers to request only a segment of a file: weak identifiers can cause such range requests to fail to hit the cache, while range requests under strong identifiers can still be cached. Because range requests require the segment obtained to strictly correspond to the entire file, since weak identifiers do not promise byte-by-byte consistency, it is uncertain whether this segment of content is still the original one. For scenarios that depend on segmented fetching of resources, strong identifiers are more suitable.

How to use sites with frequent content changes

An article revised once becomes one edition, the identifier follows the change, and the revisitor will naturally receive new content. What needs to be considered is the changeable part: if the page contains real-time statistics, personalized greetings, and other content that changes every time, the entire page identifier will change every time, and all revisit verifications will fail.Commonly, the approach is to split the variable part out into a separate request, allowing the main content to maintain a stable version, thus making the identifier constant. For static resources, the identifier is generated as usual, with a longer freshness period, and the validation after expiration usually hits 304.In addition, pay attention to the fact that a major version upgrade of the server or framework may change the calculation method of identifiers, causing all old values to not match overnight, and it is advisable to arrange for the release impact within the expected range.

Common questions

Question: Should this identification be used at the same time as judging by modification time?Answer: The two sets are independent verification methods that can coexist. If there is an old value with an identifier, compare by version; if there is a time condition, compare by time; both complement each other rather than replace each other.

Question: If a 304 without content is received, does it mean the request failed?Answer: No. 304 is a normal result of successful verification, meaning that the version in the cache is still usable, and the client will use the local copy immediately. No content means it is exactly to save the repeated transmission.

Question: Why do we never see responses without content on our site?Answer: It is usually a tag that changes every time. Check if there are fluctuations like rendering time mixed into the input, and whether the calculation methods of each node in the cluster are consistent. A revisit will only be successful if the input is stable and the content does not change.

Question: If the content is changed but the client does not receive the new version for a long time, is it related to this mechanism?Answer: It is possible. If the content changes but a new identifier value is not generated, the revisit comparison will still be consistent, and the client will continue to use the old cache. It is necessary to change the value when the content of the resource at the same address changes, and this step cannot be omitted.

Related articles

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

Why does the login lock and blacklist on the website behind the proxy recognize the source address incorrectly?

When a website is behind a reverse proxy, the program often reads the connection source as the proxy address, and the content of the forwarding header is controlled by the client. Confusing the two layers can lead to login locking and incorrect objects in the blacklist. PbootCMS has fixed the issue of unconditional trust in the source forwarding header in the update records of V3.2.25. This article discusses the origin of the two layers of addresses, the practice of taking the most right可信 value in the trusted link, and which layer to use for throttling and locking.

2026-10-12

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

TLS early data allows the client to send a request in just a few round trips, saving the next handshake wait time, but at the cost of the risk of replayed requests. 425 Too Early indicates that the server is unwilling to take the risk of processing a potentially replayed request and prefers to reject it first. This article discusses what early data saves, where the risk falls on what type of requests, why idempotent and non-idempotent need to be treated separately, and what trade-offs a service with a Go language technology stack needs to make at this level.

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