GitLab CI/CD
Feb 18, 2026 5 min read

GitLab CI Cache Not Being Restored Between Jobs

Why your `node_modules` or `.cache/` keeps re-downloading and how to make the cache actually hit.

Problem

Every job re-installs dependencies. Logs say `Cache not found` even though the previous job ran `cache:`.

Root cause

  • Different runners with separate local cache directories.
  • Cache key changes every run (e.g. uses $CI_JOB_ID).
  • Distributed cache (S3) is not configured.
  • Job runs in a different stage with `policy: pull-push` mismatch.

Solution

Use a stable, file-based cache key

yaml
cache:
  key:
    files: [package-lock.json]
  paths: [node_modules/]
  policy: pull-push

Use distributed cache when you have multiple runners

toml
# /etc/gitlab-runner/config.toml
[runners.cache]
  Type = "s3"
  Shared = true
  [runners.cache.s3]
    ServerAddress = "s3.amazonaws.com"
    BucketName = "gitlab-runner-cache"

Frequently asked questions

Related fixes

Weekly digest

One DevOps fix in your inbox each week

Short, practical, no fluff. Real errors, real fixes — straight from production postmortems.