Use cache for dependencies and artifacts for outputs.
Section: Speed and portability
GitLab cache vs artifacts
yaml
yaml
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .npm/
artifacts:
paths:
- dist/
expire_in: 1 weekExplanation
Cache is for speeding up repeated work; artifacts are for preserving job outputs.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Speed and portability
Cache npm dependencies in GitHub Actions
Reuse package manager downloads between runs.
Upload build artifacts
Publish files from one job for later download or deploy.
GitLab matrix variables
Expand one logical job into multiple combinations.
GitHub reusable workflow
Call a shared workflow from another repository or workflow file.