Pipeline Caching
About 284 wordsLess than 1 minute
During pipeline execution, many dependencies and intermediate artifacts are generated. Caching these for reuse in subsequent pipelines can effectively reduce build time.
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