---
title: "Keep the back button instant · Agent Wranglers"
url: https://agentwranglers.se/playbook/website/performance/bfcache
updated: 2026-10-20
licence: "All rights reserved"
---

# Keep the back button instant

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Recommended
- Chapter: [Performance](https://agentwranglers.se/playbook/website/performance)
- Rule: Keep every page able to use the back/forward cache, which shows a page instantly on Back. Use no `unload` handlers, and no `Cache-Control: no-store` on ordinary pages.
- How: Use `pagehide` instead of `unload`. Send `no-store` only on pages with sensitive data, such as payment, health or identity pages, as [private responses](https://agentwranglers.se/playbook/adversarial-testing/requests-and-files/private-responses-uncached) lists. Ordinary account pages use `private, no-cache`. Chrome now caches some `no-store` pages, but other browsers don't. Close open connections, such as WebSockets, on `pagehide` and reopen them on `pageshow`.
- Check: DevTools › Application › Back/forward cache reports the page as restored. A browser test goes forward and Back, and the `pageshow` event has `persisted` set to true.

Example:

```js
let socket;
const connect = () => { socket = new WebSocket("wss://example.com/live"); };
connect();
addEventListener("pagehide", () => socket.close());
addEventListener("pageshow", (e) => {
  if (e.persisted) connect(); // restored from the back/forward cache
});
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers website playbook: https://agentwranglers.se/playbook/website/performance/bfcache`.

- Previous: [Fetch the next page on hover](https://agentwranglers.se/playbook/website/performance/speculation-rules)
- Next: [Skip work for what is off screen](https://agentwranglers.se/playbook/website/performance/visibility-aware-rendering)
- [Performance](https://agentwranglers.se/playbook/website/performance)
