build cache
Saved results of earlier build steps that a build tool, such as Docker, reuses when nothing a step depends on has changed.
In more detail
A build cache stores each step's output under a key derived from its inputs, so an unchanged step is replayed instead of rerun. Changing an early input invalidates that step and everything after it. So put rarely changing steps, such as installing dependencies, first and often changing ones, such as copying source code, last.
Example
Turborepo keeps each task’s outputs under a hash of its inputs; the demo prints HIT for a match and MISS for a new hash.Related terms
- layer — One read-only slice of an image that records the files a single build step added, changed or deleted.
- Dockerfile — A text file of instructions, such as FROM, COPY and RUN, that tells Docker how to build an image.
- COPY — The Dockerfile instruction that copies files from the build context into the image.
- RUN — The Dockerfile instruction that runs a command during the build and saves the result as a new layer.
- cache — A store of earlier answers kept close to where they are needed so they can be reused instead of fetched or computed again.
- remote caching — Storing build outputs on a shared server so that any developer or CI machine with the same inputs can download the result instead of rebuilding.
- hash — A short fixed-length fingerprint calculated from data, which changes completely if even one byte of the data changes.
Taught in
- Container Images The Exam Way — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Union Filesystems, Images And Writable Layers — Docker Architecture & Production Containers
- Build Context, Dockerignore And Your First Dockerfile — Docker Architecture & Production Containers
- RUN, SHELL And Efficient Layer Caching — Docker Architecture & Production Containers
- Multi Stage Builds, Targets And Build Secrets — Docker Architecture & Production Containers
- Build, Test And Promote The Same Image In CI — Docker Architecture & Production Containers
- Unified Build Pipelines: Caching & Dependency Graphs — Production Full-Stack Engineering
- Containerization Architecture: Multi-Stage Dockerfiles — Production Full-Stack Engineering