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

📅 October 12, 2026 👁️ 29

After the user logs out, the browser still retains cache and storage. How do you require the clearing of headers, it relies on a clearing signal emitted by the server, not on the script in the page itself deleting. This signal is the Clear-Site-Data response header: the server includes it in the response of the logout interface, which is equivalent to giving the client the instruction of 'which types of browsing data to clear'. The browser then executes local cleaning item by item. It can only express two things: which types of data to clear and to what extent, the rest depends on whether the client cooperates.

Why do you need to clear the login page actively?

The login status is issued by the server: credentials are issued when the session is established, and the credentials are invalidated when the session is logged out. The browser records another set of accounts, page, script, and interface response will enter the cache, and business code may also write intermediate results into the local storage. These contents are not bound to the session and will not disappear automatically when the session expires.

Therefore, a misalignment occurs: the user has clicked logout, and the server has turned the page, with the old data still lying on the device. When the next person opens the site on the same machine and the same browser, even if they cannot get a new session, they may still see the content of the previous page from the residue. Actively clearing it is to align both sides.

Within the station, the login state is carried by JWT, the server-side logout and session expiration are on one side, and the browser's local cache and storage need to be cleared with this response header. As for these two points, no other expectations should be derived.

Which types of local data can be cleared

Instructions are given item by item, multiple items can be listed in one response, and the client only handles the listed items. Common items and the things they manage are as follows.

Items to clear General scope of action Why is it needed when logging out
cache The cache content saved by the browser for this site Collect the residual page and interface response with the login context
cookies Credentials under the entire registration domain, including all subdomains Clear the login credentials scattered across multiple subdomains in one go
storage Local storage corresponding to the source of the response The intermediate data written into local storage by the script ends with it
executionContexts The current relevant execution context End the running script environment all at once, don't let old code continue to hold data

If the list is too short, the end will not be clean, and if the list is too long, it will hurt the things the user intends to keep

Why only effective in encrypted connections

This ability is only available in a secure context, and when deployed, it means that the response must go through an encrypted connection, that is, HTTPS. If this header is added to a plaintext connection, the browser will not comply, and no cleaning action will occur.

The reason is not difficult to understand: it requires deleting local data, which has a significant impact, and browsers do not accept signals that may be tampered with or forged by intermediate links. The conclusion is to first confirm that the entire site uses an encrypted entry, and then discuss whether this header is effective; if it was added in the test but did not work, first check whether the access path is an encrypted connection.

Whether the clearing scope is to the source or to the registered domain

Different items have different landing points, which is the most confusing part.

The impact of cookies is the entire registration domain, including its subdomains. When multiple subsystems under the main domain share the same set of login credentials, a single command can cover them all, without the need to process each domain individually.

Storage clears the local storage corresponding to the response source. The source is determined by the protocol, host, and port. Changing the host or protocol is another source, which will not be cleaned together.

The difference here has real significance: To collect clean credentials, it relies on the scope of the registration domain; To accurately store locally, it needs the response with this prefix to appear at the actual source of data writing.

Why is it more worth adding this layer on public devices?

The residue on a private device mainly affects the user themselves. Public devices are different: front desk tablets, shared terminals in workshops, and machines used by multiple people in rotation. After the previous person logs out, the browser is not under their control, and the next person takes over the same local data directly. In such scenarios, the server's unilateral cancellation of the session does not clean up the traces of the previous person, and the cleaning at the client level fills the gap.

Also, be aware of its unreliability: the server can only send signals, whether it is cleared and cleared clean depends on the client, browsers that do not cooperate can completely ignore this instruction, and the degree of support for different items by different browsers is also different. Since September 2023, this capability has been generally available in browsers, but general availability does not mean that the performance of each item is consistent.

Therefore, it cannot replace the server-side session revocation. Invalidating credentials, revocation records, and cleaning up the state on the server side still need to be done on the server side, this level is the closing, not the itself of the security boundary.

Common questions

Ask: What are the consequences if the logout interface only invalidates the session without returning this header?Answer: The server side is clean, but the cache and local storage accumulated during the browser's visit are still left on the device. When someone else uses it, these remnants may be found by the next person.

Ask: Can you only issue it at the moment of logout?Answer: Yes, it performs a deletion action, the cost is borne by the client; placed on the interface for confirming the end of the session, the semantics are clear, and it will not clear the data the user is using in normal browsing.

Ask: If I clear the cookies, does it mean all local data is cleared?Answer: Not equal. Cookies cover the credentials under the registration domain, local storage belongs to another item, cache is also calculated separately, and it is effective to list them separately.

Related articles

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

How should the deletion range be verified for the batch deletion interface of background messages according to parameter concatenation?

If the batch deletion of background messages directly concatenates the number list sent from the front-end into the deletion conditions, it may delete out-of-range content in one request. PbootCMS has fixed this kind of parameter injection in the update records of V3.2.18, strictly checking the id list to be deleted. This article explains why the batch interface has expanded the impact range, how to verify the type and existence of the number, why the deletion range needs to be recalculated on the server side, and what the recycle bin can accommodate after accidental deletion.

2026-10-12

The template tag outputs the opening tag of the script, how can the content be executed as code?

PbootCMS has fixed the risk of script tag output in site tag output script and enhanced tag page parameter filtering - when editable content enters the template engine with opening tags, the data will be treated as code. This article explains where the step of data becoming code occurs, why the tag output position needs to be filtered, and why HTML, attributes, scripts, and URLs need to be escaped separately, as well as why filtering earlier saves time and has a layered closing effect.

2026-10-11

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

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

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