HTTP Headers
Clear Site Data
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The HTTP Clear-Site-Data
response header indicates to the client that it should remove specific types of browsing data, such as cookies, storage, and cache, associated with the website making the request.
It enables web developers to have greater control over the data stored by browsers for their websites.
Syntax
// Single directive
Clear-Site-Data: "cache"
// Multiple directives (comma separated)
Clear-Site-Data: "cache", "cookies"
// Wild card
Clear-Site-Data: "*"
Directives
- The server signals that the client should remove locally cached data (the browser cache, see HTTP caching) for the origin of the response URL. Depending on the browser, this might also clear out things like pre-rendered pages, script caches, WebGL shader caches, or address bar suggestions.
- Indicates that the server will remove all client hints (requested via “Accept-CH”) stored for the origin of the response URL.
Note: In browsers that support the “clientHints” data type, client hints are also cleared when the “cache”, “cookies”, or “*” types are specified. “clientHints” is therefore only needed when none of those other types are specified.
- The server signals that the client should remove all cookies for the origin of the response URL. HTTP authentication credentials are also cleared out. This affects the entire registered domain, including subdomains. So
https://example.com
as well ashttps://stage.example.com
, will have cookies cleared. - The server signals that the client should remove all DOM storage for the origin of the response URL. This includes storage mechanisms such as:
- localStorage (executes
localStorage.clear
) - sessionStorage (executes
sessionStorage.clear
) - IndexedDB (for each database execute
IDBFactory.deleteDatabase
) - Service worker registrations (for each service worker registration, execute
ServiceWorkerRegistration.unregister
) - Web SQL databases (deprecated)
- FileSystem API data
- Plugin data (Flash via
NPP_ClearSiteData
)
- The server signals that the client should reload all browsing contexts for the origin of the response (“Location.reload”).
- The server signals that the client should clear all types of data for the origin of the response. If more data types are added in future versions of this header, they will also be covered by it.
Example
If a user signs out of your website or service, you might want to remove locally stored data. To do this, add the Clear-Site-Data
header to the page that confirms the logging out from the site has been accomplished successfully (https://example.com/logout
, for example):
Clear-Site-Data: "cache", "cookies", "storage", "executionContexts"
Clearing cookies
If this header is delivered with the response at https://example.com/clear-cookies
, all cookies on the same domain https://example.com
and any subdomains (like https://stage.example.com
, etc.), will be cleared out.
Clear-Site-Data: "cookies"
How to Modify Header using Requestly
Requestly is a powerful Chrome extension that allows you to modify HTTP headers, including the Clear-Site-Data header.
This is especially useful for managing how browsers clear cached data when debugging or testing your website. Steps to Modify the Clear-Site-Data Header:
- Install and open the Requestly Chrome extension. You can find it on the Chrome Web Store.
- Create a new rule: Click on “Create Rule” and choose “Modify Headers” from the list of available rule types.
- Add a new header modification:
- Under “Action”, select “Add” or “Override”.
- In the “Header Name” field, enter Clear-Site-Data.
- In the “Header Value” field, enter the desired directive(s), for example “cache”, “cookies”, “storage”, or “*”.
- Set the URL condition: Specify the URL or pattern where this header change should apply (e.g., https://your-website.com/*).
- Save the rule.
Once set up, Requestly will inject the Clear-Site-Data header with your specified directives into all matching requests, helping you test how clearing caches, cookies, or other stored data affects your site. You might need to modify the Clear-Site-Data header to control what data browsers clear in specific scenarios, such as after a logout or during testing. This helps ensure your web application behaves correctly with fresh data or without stored cookies or cache.
Table of Contents
- No headings found.