Interview Prep/GitHub Actions/Speed, Caching & Cost

The repo hits the 10 GB cache limit daily and hit rates are poor. What do you change?

IntermediateScenarioSpeed, Caching & Cost
Answer

Situation read → Cache thrashing: too many large, unique caches.

What I'd do →

  1. gh cache list --sort size_in_bytes --limit 30 to find the biggest keys.
  2. Save caches only on main (actions/cache/restore everywhere, actions/cache/save with if: github.ref == 'refs/heads/main').
  3. Remove github.sha or run IDs from keys where not needed.
  4. Give Docker caches a scope and move big ones to registry cache.
  5. Delete PR caches on PR close (gh cache delete --ref refs/pull/N/merge in a cleanup workflow).

Why → LRU eviction across branches throws away the useful main caches first when PRs flood the store.

Interview tip → "Write caches on main, read them everywhere."

All GitHub Actions questions Roadmap: GitHub Actions

More on Speed, Caching & Cost