# Build cache and images

Source: https://openpanel.sh/docs/builds/cache

What each server keeps between builds, how much, and how it is cleaned up.

Builds run on your own servers, so the cache and the images they leave stay there too. OpenPanel's agent keeps them within bounds.

## The build cache [#the-build-cache]

- **Docker's build cache.** Builds reuse the layers and cache of earlier builds on the same server, the way Docker always does, so a build that changes little is quick.
- **Per service, for Railpack.** A Railpack build keeps its package managers' caches, such as npm's or pip's, under a key of its own service, so one service's cache never mixes with another's.
- **On each server.** A server's cache serves the builds on that server only. A service built on another server starts without it.

## How much is kept [#how-much-is-kept]

| What | Kept |
|---|---|
| **Build cache** | The newest 5 GB on each server. |
| **Deployment images** | The newest five deployments' images of each service, plus any a container runs now. |
| **Images builds left without a name** | None. |

The agent prunes every 6 hours, after builds, and within the hour while the server's disk is 80% full or more. It never removes an image that OpenPanel did not pull or build, and Docker refuses to remove an image a container uses.

To keep more build cache on a server that builds a lot, set `OPENPANEL_BUILD_CACHE_KEEP_GB` for its agent, in gigabytes:

```sh
sudo systemctl edit openpanel-agent
```

```ini
[Service]
Environment=OPENPANEL_BUILD_CACHE_KEEP_GB=20
```

```sh
sudo systemctl restart openpanel-agent
```

## Resources a build may use [#resources-a-build-may-use]

A build is not limited: it uses the server's processors and memory beside the services that already run there, and a server runs one build at a time. On a small server, a large build can slow its other services while it runs. The [limits you set on a service](/docs/projects/settings) apply to its containers, not to its build.

## Build output [#build-output]

What a build prints is in the deployment's events for two days. See [How builds work](/docs/builds#build-output).