# Demo offline with mock sets

> Record an app's API traffic once, then replay it with no network using a Mock Set, so a demo works on a plane or a flaky conference Wi-Fi.

Source: https://docs.subcloak.com/cloak-proxy/guides/demo-offline-with-mock-sets/

You have a demo on a plane or on conference Wi-Fi you can't trust. This guide records your app's API responses once while the network is good, then replays them with no network at all using a **Mock Set**, so the app behaves exactly as it did when you recorded it. It also shows the headless `cloakctl` equivalent.

## What you need

| | |
|---|---|
| Cloak Proxy capturing the app, with HTTPS decrypted | See [Debug a mobile app](https://docs.subcloak.com/cloak-proxy/guides/debug-a-mobile-app/) or [macOS traffic](https://docs.subcloak.com/cloak-proxy/capture/macos-traffic/) |
| A good network for the recording pass | You're capturing the real responses to replay later |

## Record the demo path

1. With capture and decryption on, run through the exact demo you'll give: open every screen, scroll the lists, tap into the details. A Mock Set can only replay requests it recorded.

2. If a screen loads more as you scroll (pagination), scroll it during recording so those pages are captured too.

> **Tip:**
> Record a little more than the demo needs. Anything you skip now will return a 404 later in strict offline mode.

## Snapshot the responses into a Mock Set

**From a whole domain**

Right-click the app's domain in the sidebar and choose **Mock _host_ Offline**. Every captured response from that host becomes a strict offline set, and the Mock Sets tool opens with it selected.

**From selected requests**

Select the requests in the list and choose **Tools → Mock Sets → From Selected Requests**. Only those responses are recorded.

*[Screenshot: The Mock Sets tool with a set, an Offline checkbox ticked, a query-string option, and a table of recorded responses. A Mock Set with Offline on: nothing reaches the real host while it's on.]*

1. Leave **Offline: answer unrecorded requests to these hosts with 404** on. This guarantees the demo never touches the network, so a dropped connection can't break it.

2. If your demo requests differ slightly from the recording (a timestamp or token in the query), turn on **Ignore query strings when matching** so `/feed?token=…` still matches.

3. Select any response to fix it up before the demo — change a name, a price, a status — the same editor as [Map Local](https://docs.subcloak.com/cloak-proxy/tools/map-local/).

> **Note:**
> The most recent recording of a request wins when the same request was captured more than once, so a later, cleaner capture overrides an earlier one in the same set.

## Run the demo offline

1. Turn the set on with the switch at the top of the Mock Sets tool. The **N tools on** count in the bottom bar includes it while it's on.

2. Disconnect from the network (or just unplug Wi-Fi to prove it). Use the app: matching requests are answered from the snapshot, tagged **Mock** in the traffic list.

3. Any request you didn't record returns a 404 with a body that says which request wasn't in the set — a useful hint if a screen looks empty.

> **Caution:**
> With a device, remember the device still needs the Wi-Fi proxy pointed at your Mac and the certificate trusted for the Mock Set to answer it. "Offline" means no internet is needed, not that the device and Mac are disconnected from each other.

## The headless equivalent

To record and replay from the command line, use the CI recorder. This is handy for a scripted demo or an offline test run.

```bash title="Terminal"
# Record real traffic while a command runs
cloakctl run --ssl '*' --record demo.har -- ./run-the-app.sh

# Later, replay it offline — no network needed
cloakctl run --mock demo.har --quiet -- ./run-the-app.sh
```

`--mock` loads the HAR as a Mock Set and answers requests from it. See [cloakctl](https://docs.subcloak.com/cloak-proxy/automation/cloakctl/) and [Headless and CI](https://docs.subcloak.com/cloak-proxy/automation/headless-and-ci/).

> **Tip:**
> You can also feed a recording into the app: **Tools → Mock Sets → Import HAR or Session…** turns a `.har`, `.cloaksession` or Charles `.chlsj` file into a set.

## Clean up

1. After the demo, turn **Mock Sets** off with the switch so the app talks to the real backend again.

2. Keep the set for next time, or select it and press the minus button to delete it.

3. On a device, remove the Wi-Fi proxy and profile when you're done (see [iPhone and iPad](https://docs.subcloak.com/cloak-proxy/devices/iphone-and-ipad/)).

## Related

  - [Mock Sets](https://docs.subcloak.com/cloak-proxy/tools/mock-sets/): Record, edit and replay responses offline.
  - [Mock a backend](https://docs.subcloak.com/cloak-proxy/guides/mock-a-backend/): Map Local and mock servers for building responses.
  - [Headless and CI](https://docs.subcloak.com/cloak-proxy/automation/headless-and-ci/): cloakctl run --record and --mock for scripted runs.
  - [Import](https://docs.subcloak.com/cloak-proxy/sessions/import/): Bring in HAR, Charles and cURL recordings.
