---
title: Docker build cache
linkTitle: Cache
weight: 60
description: Improve your build speed with effective use of the build cache
keywords: build, buildx, buildkit, dockerfile, image layers, build instructions, build context
aliases:
- /build/building/cache/
- /build/guide/layers/
---
When you build the same Docker image multiple times, knowing how to optimize
the build cache is a great tool for making sure the builds run fast.
## How the build cache works
Understanding Docker's build cache helps you write better Dockerfiles that
result in faster builds.
The following example shows a small Dockerfile for a program written in C.
```dockerfile
# syntax=docker/dockerfile:1
FROM ubuntu:latest
RUN apt-get update && apt-get install -y build-essentials
COPY main.c Makefile /src/
WORKDIR /src/
RUN make build
```
Each instruction in this Dockerfile translates to a layer in your final image.
You can think of image layers as a stack, with each layer adding more content
on top of the layers that came before it: