This site is open for sponsorshipHow it works →
CI cost figures are vendor list prices verified November 2026. Actual cost depends on plan, concurrency, and discount terms. Vendor links are direct, unpaid. How we work.

Updated December 2026 · 9 min read

The CI caching playbook

Caching is the single biggest free lunch in CI. Three quarters of pipelines either misuse it or skip it entirely. A fresh npm install takes 60-180 seconds. Cached, it takes 3-10 seconds. The ROI on a well-configured cache is near-instant and the savings compound across every PR.

§ 01

Layer 1: Dependency caching

Dependency caching is the fastest win available. See the dedicated dependency caching recipes page for per-ecosystem YAML for npm, pnpm, yarn, pip, poetry, maven, gradle, composer, cargo, go modules, and bundler.

§ 02

Layer 2: actions/cache (GitHub Actions native)

The actions/cache@v4 action provides a key-value cache store scoped to your repository. The most important detail: the 10 GB repository-wide cap. When the cap is reached, GitHub evicts the least recently used caches first.

- uses: actions/cache@v4
  with:
    path: ~/.npm
    key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
    restore-keys: |
      ${{ runner.os }}-node-

Cache key strategy: hash the lockfile (package-lock.json, yarn.lock, pnpm-lock.yaml), not the package.json. Include the OS in the key. This gives you OS-specific caches that survive lockfile changes gracefully via the restore-keys fallback.

§ 03

Layer 3: Docker layer cache

Docker layer caching is one of the highest-ROI optimisations for teams that build container images in CI. See Docker build optimisation for the full recipe including cache-from: type=gha and registry cache backends.

§ 04

Layer 4: Turborepo remote cache

Turborepo remote cache stores task outputs (build artefacts, test results) in a shared cache. On a cache hit, Turborepo skips the task entirely and replays the output. The saving is the share of tasks whose inputs did not change, so it grows with the number of packages a typical PR leaves untouched.

Vercel hosts Turborepo remote cache for free for small teams. The self-hosted option uses S3 or R2 with a simple adapter. See monorepo strategies for cost comparisons.

# With Vercel Remote Cache
- run: npx turbo build test --filter='...[origin/main]'
  env:
    TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
    TURBO_TEAM: your-team-name
§ 05

Layer 5: Nx Cloud

Nx Cloud provides remote cache plus distributed task execution. The free Hobby tier includes 50,000 credits a month for up to 5 active contributors. The Team plan starts at $29 a month, includes 5 active contributors then charges $19 for each additional one, and bills credits at $5.50 per 10,000 (nx.dev/pricing, read 24 November 2026). For large monorepos (50+ packages), the distributed execution feature can be as valuable as the cache itself.

Nx affected commands (nx affected:build) are the monorepo equivalent of the paths filter: run only what changed.

§ 06

Layer 6: Bazel remote cache

Bazel remote cache stores build artifacts keyed on a content-addressable hash of inputs. At scale, a warmed Bazel remote cache rebuilds only the targets whose inputs changed; Uber reports halving its Go monorepo build time with one (see the case studies). The trade-off is Bazel setup cost: typically 2-6 months of migration for a large codebase.

Uber reports that moving its Go monorepo remote cache to Buildfarm cut build time by about half, and that a shared gRPC cache had already brought p95 from 40-100+ minutes to consistently below 40. See case studies for the full analysis.

§ 07 · WHEN CACHING HURTS

When caching hurts

Small repositories with rapid dependency churn

If your lockfile changes on every PR, most runs miss the cache. At that point, cache restore + save time exceeds fresh install time for small dependency trees.

Too-broad cache keys

A cache key based on the entire repository hash (not just the lockfile) produces near-zero hit rates. Every commit creates a new cache key with no restore candidate.

Cache storage cost on heavy-artefact teams

GitHub Actions charges $0.25/GB/month for storage above the free allocation. A team storing 500 MB Docker build caches on every PR can exceed the free 500 MB in two builds. Monitor storage usage.

Security: never cache build output of untrusted code

If you run CI on forks (PRs from external contributors), cache poisoning is a real attack vector. Do not use read-write caches on fork builds; use read-only restore with a write cache only on main/merge-queue builds.

§ 08

Worked cost example

ILLUSTRATIVE: 10-DEV JS MONOREPO, 80 PR RUNS/DAY, 22 WORKING DAYS, $0.006/MIN LINUX (RUN TIMES ASSUMED)

Baseline: 9 min/PR x 80 PRs/day x 2215,840 min/mo → $95/mo
Add dependency cache: 5 min/PR8,800 min/mo → $53/mo
Add Turborepo remote cache: 2 min/PR3,520 min/mo → $21/mo
Add Docker layer cache: 1.5 min/PR2,640 min/mo → $16/mo
On these assumed run times83% lower

DIGITAL SIGNET · PIPELINE AUDIT

Cache audit: identify every missing cache in your pipeline.

Digital Signet reviews your workflow definitions, identifies uncached dependency installs and Docker builds, and delivers a prioritised set of YAML diffs to implement.

Get an Audit

Updated 2026-12-05