Git & GitHub Interview Question #97
What is caching in GitHub Actions?
GitHub Collaboration, Repository Rules, Issues, Releases & Actions CI/CD Mid-Level Intermediate
Quick Interview Answer
Caching stores reusable dependency or build data so later workflow runs can avoid downloading or regenerating the same content. Good caching can reduce CI execution time and external network usage.
Detailed Explanation
Caching stores reusable dependency or build data so later workflow runs can avoid downloading or regenerating the same content. Good caching can reduce CI execution time and external network usage.
Cache keys must reflect the inputs that make cached data valid, such as dependency lock files or operating system. Incorrect caching can produce stale or confusing builds, so caches should be treated as an optimization rather than the source of truth.
Code Example
- uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
cache: true
# Exact caching strategy depends on the project
# and dependency-management files.