Clear-Site-Data Header

Table of Content

The HTTP Clear-Site-Data header is used to delete specific types of data associated with a website from the user's browser. It is a mechanism by which the server can instruct the user-agent to remove one or more types of data. This is useful for situations where you would like to force a log-out or clear data for security reasons or as part of switching accounts.

Syntax

Clear-Site-Data: "directives"

Directives

The following directives can be used with the Clear-Site-Data header:

  • "cache": Clears locally cached data and files.
  • "cookies": Clears cookies. HTTP authentication credentials are also treated as cookies.
  • "storage": Clears localStorage, sessionStorage, IndexedDB, and WebSQL data structures.
  • "executionContexts": Reloads the webpage in all browsing contexts.

Note that each directive is quoted and multiple directives are separated by commas.

Examples

Deleting all types of data:

Clear-Site-Data: "*"

Deleting only cookies and cache:

Clear-Site-Data: "cookies", "cache"

Browser Compatibility

Browser Compatibility
Chrome Supported
Firefox Supported
Safari Not Supported
Opera Supported
Edge Supported

How to modify Clear-Site-Data header

ModHeader is a Chrome extension that can modify request and response headers. With ModHeader, you can modify the Clear-Site-Data header as you want. Suppose you're developing your website and need to check the behavior when the Clear-Site-Data header is received.

  1. Install ModHeader from the Chrome Web Store.
  2. Click the ModHeader icon to open the extension, then click + to add a new profile.
  3. In the 'Response headers' section, click + to add a new header.
  4. Set 'Header name' to Clear-Site-Data, and 'Header value' to the directive you want to test, such as "cache".
  5. Reload your website. The browser will act as if it received a Clear-Site-Data: "cache" header from the server.

Note that this doesn't affect the actual data on your server, it's a way to simulate different responses for testing purposes.