Interview Prep/GitHub Actions/Speed, Caching & Cost

A Go monorepo build is slow because the Go build cache is cold. Optimize.

IntermediateScenarioSpeed, Caching & Cost
Answer

Situation read → Two caches matter: module download cache and build cache.

What I'd do →

  1. actions/setup-go@v5 with go-version-file: go.mod (caching on by default, keyed on go.sum).
  2. Set cache-dependency-path for multiple modules: "**/go.sum".
  3. Restore-only on PRs, save on main if cache churn is a problem.

Why → The build cache (~/.cache/go-build) avoids recompiling unchanged packages.

Interview tip → Know the two directories: GOMODCACHE and GOCACHE.

All GitHub Actions questions Roadmap: GitHub Actions

More on Speed, Caching & Cost