# Caching

Resource cache behavior and invalidation.

## Data caching

The data library automatically caches all query results in `ext/data/.tmp/cache/`. The cache is invalidated when a record in the queried resource is saved, added or removed, by the site, the API, Git or `ext:sync`, and when its `.meta` is edited. No manual cache management is needed for any of those.

One case is not seen: a record file edited in place by hand (an editor that writes into the existing file). A cached list shows the old values until the next write to that resource. Clear the cache after such an edit:

```bash
./nimbly data:cache:clear
```

The admin dashboard has the same action, `Clear data cache`.

---

## `data:cache:clear`
Throws away the cached query results of every resource; the next read builds them again. Use this after editing a record file in place by hand (see Data caching). Saving through the site, the API, Git or `ext:sync` needs no clearing.

```bash
php core/cli/nimbly.php data:cache:clear
```
