2023-08-29 · CI-CD
Cache dependencies to cut CI build time
Hash lockfiles correctly, restore on cache misses, and stop shipping stale node_modules.
Introduction
A practical setup for GitHub Actions and GitLab CI, with hit-rate numbers from a mid-size monorepo.
What usually goes wrong
Teams that skip this step tend to share three failure modes:
- Optimizing a number nobody agreed to move.
- Copying a setup from a project with different constraints.
- Deferring the decision until it is expensive to reverse.
How to approach it
- State the problem in one sentence, in the words your users would use.
- Pick a signal you can measure weekly, not just at launch.
- Timebox a small trial; a two-day spike beats a two-week debate.
Wrap-up
If CI-CD taught us anything, it is that boring consistency beats clever one-offs. Bring the lessons back to your team before they fossilize into folklore.