---
title: "Clear cached pages and data when someone · Agent Wranglers"
url: https://agentwranglers.se/playbook/application-security/authentication-and-sessions/clear-site-data-on-sign-out
id: APS-19
level: Required
applies: accounts
risk: data
updated: 2026-10-27
build: a2a6bdfed830
tokens: 1049
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Clear cached pages and data when someone signs out

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Authentication and sessions](https://agentwranglers.se/playbook/application-security/authentication-and-sessions.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: APS-19
- Level: Required
- Chapter: [Authentication and sessions](https://agentwranglers.se/playbook/application-security/authentication-and-sessions.md)
- Rule: On sign-out, delete everything the browser stored for the account. That covers the service worker's caches, local storage and cookies.
- Check: A browser test signs in, opens the account page, and signs out. Afterwards `caches.keys()` returns an empty list, local storage is empty, and the account page is not served while offline.
- Risk: Data leaked or lost
- Applies when: The project has user accounts.
- How: A service worker that cached a signed-in page shows it to the next person on a shared device, even after sign-out. Send `Clear-Site-Data: "cache", "cookies", "storage"` on the sign-out answer. Browsers that support it then drop caches, storage and service worker registrations for the site. Also delete the caches from the page with `caches.delete` before the redirect, for browsers that ignore the header. End the session on the server too, as [Let people sign out of one device or all of them](https://agentwranglers.se/playbook/accounts/sessions-and-security-activity/revoke-sessions.md) says. Better still, never cache private answers in the worker, as [Keep working when the network drops](https://agentwranglers.se/playbook/website/offline-and-installed-apps/offline-support.md) says.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript example

```js
app.post('/sign-out', (req, res) => {
  req.session.destroy(() => {
    res.set('Clear-Site-Data', '"cache", "cookies", "storage"').redirect(303, '/');
  });
});
```

### Python example

```python
@app.post("/sign-out")
def sign_out(request: Request):
    request.session.clear()
    response = RedirectResponse("/", status_code=303)
    response.headers["Clear-Site-Data"] = '"cache", "cookies", "storage"'
    return response
```

## Sources

- [W3C Clear Site Data](https://www.w3.org/TR/clear-site-data/)
- [OWASP Session Management Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html)

## Related rules

- ACC-32 [Put sign-out on every signed-in page](https://agentwranglers.se/playbook/accounts/sessions-and-security-activity/sign-out-link.md) in Accounts and identity
- APP-76 [Keep tokens and sensitive data out of browser storage](https://agentwranglers.se/playbook/app-ui/client-and-server-state/sensitive-data-out-of-browser-storage.md) in Web app interface
- APP-59 [Sign out every open tab together](https://agentwranglers.se/playbook/app-ui/sessions-and-permissions/sign-out-all-tabs.md) in Web app interface
- ACC-28 [Let people sign out of one device or all of them](https://agentwranglers.se/playbook/accounts/sessions-and-security-activity/revoke-sessions.md) in Accounts and identity
- WEB-224 [Keep working when the network drops](https://agentwranglers.se/playbook/website/offline-and-installed-apps/offline-support.md) in Website

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/application-security/authentication-and-sessions/clear-site-data-on-sign-out">Agent Wranglers application security playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Block cross-site form posts](https://agentwranglers.se/playbook/application-security/authentication-and-sessions/cross-site-requests.md)
- [Authentication and sessions](https://agentwranglers.se/playbook/application-security/authentication-and-sessions.md)
