# Get started with the cache

> Turn the edge cache on for a zone or one name, check a static file goes from MISS to HIT, and add a rule for HTML if you want it.

## Before you begin

- A zone with at least one proxied name. See [DNS](https://developers.openwaf.dev/dns/).
- The `tech` or `admin` role.

## Turn on the cache

**Dashboard**

1. Open the zone and go to **Caching**.
2. Turn on **Cache at the edge**. Use **Scope** to apply it to the whole domain or a single name.
3. Select **Save changes** and give a reason.

**CLI**

```sh
openwaf-cloud ctl zones set example.com cache.enabled:=true --reason "cache static files"
# Only one name:
openwaf-cloud ctl zones set example.com --host static.example.com cache.enabled:=true --reason "cache static files"
```

**API**

```sh
curl -s -X PATCH https://dash.openwaf.dev/v1/orgs/$ORG/zones/$ZONE/edge \
  -H "Authorization: Bearer $OPENWAF_TOKEN" \
  -H "Content-Type: application/json" \
  -H "X-Change-Reason: cache static files" \
  -d '{"cache": {"enabled": true}}'
```

**MCP**

`update_settings` with `{"zone": "example.com", "settings": {"cache": {"enabled": true}}, "reason": "cache static files"}`: first `confirm=false` to see the diff, then `confirm=true` with `expected_version`.


The change reaches the edge nodes with their next configuration, usually within seconds.

## Check that it works

Request a static file twice:

```sh
curl -sI https://www.example.com/app.css | grep -i -E 'x-cache-status|cache-status|age'
```

The first answer is a `MISS` (fetched from the origin and stored); the next ones from the same edge node are `HIT` with an `Age`:

```http
x-cache-status: HIT
cache-status: OpenWAF; hit
age: 42
```

An HTML page answers `DYNAMIC`: HTML isn't cached by default. See [Cache status headers](https://developers.openwaf.dev/cache/cache-status/) for every value.

> **Note**
>
> Each edge node has its own cache. A request served by a different node may be a `MISS` even though another node already has the file.


## Next steps

- [Default behavior](https://developers.openwaf.dev/cache/default-behavior/): what is cached and for how long.
- [Cache rules](https://developers.openwaf.dev/cache/cache-rules/): cache HTML, or bypass admin and logged-in visitors, with ready-made templates.
- [Purge the cache](https://developers.openwaf.dev/cache/purge/): remove content after a deploy.
