Pipeline Caching
About 312 wordsAbout 1 min
Pipeline Caching explains how to cache dependencies and intermediate artifacts to shorten subsequent builds.
When to use: when every build re-downloads dependencies and takes 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 risks with 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
During builds, files like 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 efficiently reused 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, you can build the content to be cached into a Docker image for cross-node sharing.
For specific methods, reference the built-in task: docker:cache