# Caches

On Linux runners the caches are on the same box as the job, so nothing in the workflow changes to use them. On macOS, `actions/cache` saves and restores on the Mac the job runs on (see [caching Swift packages and Xcode builds](https://groundbox.dev/docs/ci/macos#macos-cache)). Windows jobs use GitHub's own cache service.

- **Package mirrors:** npm, PyPI, crates, apt and Docker Hub.
- **Actions caches:** `actions/cache` and the caches the `setup-*` actions keep.
- **Docker layers:** a stock `docker build` reuses layers from earlier builds, with no cache flags.

A layer is reused only when everything before it is unchanged. Copy the lockfile and install packages before you copy the rest of the source, so a code change does not reinstall every package:

```
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
COPY . .
RUN pnpm build
```

Actions caches and Docker layers are kept per team and repository. The package mirrors hold only public packages and are shared by every team; a request that carries credentials goes straight to the registry and is not stored.
