---
title: "Clear cached pages and data when someone · Agent Wranglers"
url: https://agentwranglers.se/playbook/website/when-things-break/clear-site-data-on-sign-out
id: WEB-265
level: Required
applies: accounts
risk: data
updated: 2026-10-22
tokens: 794
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 [When things break](https://agentwranglers.se/playbook/website/when-things-break.md).

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

- ID: WEB-265
- Level: Required
- Chapter: [When things break](https://agentwranglers.se/playbook/website/when-things-break.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. Better still, never cache private answers in the worker, as [Keep working when the network drops](https://agentwranglers.se/playbook/website/when-things-break/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/)

## Related rules

- WEB-224 [Keep working when the network drops](https://agentwranglers.se/playbook/website/when-things-break/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/website/when-things-break/clear-site-data-on-sign-out">Agent Wranglers website playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Give the installed app a fixed identity](https://agentwranglers.se/playbook/website/when-things-break/manifest-id-and-scope.md)
- Next: [Choose a caching strategy for each kind of request](https://agentwranglers.se/playbook/website/when-things-break/service-worker-strategies.md)
- [When things break](https://agentwranglers.se/playbook/website/when-things-break.md)
