Pipeline Caching
About 308 wordsAbout 1 min
Pipeline Caching explains how to cache dependencies and intermediate artifacts to shorten subsequent builds.
When to use: when builds repeatedly re-download dependencies and take too long — for example caching a package manager's dependency directory or compiled intermediate artifacts so later pipelines on the same node can reuse them.
Runner Node Caching
To balance single-point-of-failure risk against cache hit rates, pipelines are assigned to 3 runner nodes by default (the number adjusts dynamically with resource usage).
Tips
Node assignments are not permanent; they may change as the platform scales.
Code Caching
When a pipeline executes, it automatically pulls code to the runner node and caches it for reuse by subsequent pipelines.
File Caching
Files produced during builds, such as project dependencies and build caches, can be cached on the runner node for reuse by subsequent pipelines.
Declare the cache directories through docker.volumes. The following example caches the npm dependency directory on the runner node, so subsequent builds can reuse it without downloading dependencies again:
main:
push:
- docker:
image: node:20
volumes:
- /root/.npm:copy-on-write # Cache npm dependencies for reuse
stages:
- name: install
script: npm install
- name: test
script: npm testcopy-on-writeleveragesOverlayFSinstant-copy technology, allowing caches to be reused efficiently under high concurrency.- See grammar for volume types and formats.
Cross-Node Caching
Node caching takes effect on the current runner node only. To share the same cache across all nodes, build the content to be cached into a Docker image.
For details, see the built-in task docker:cache.