Debug-action-cache !!better!! -
gh api -H "Accept: application/vnd.github+json" /repos/owner/repo/actions/caches Use code with caution. Delete a Corrupt or Outdated Cache
GitHub caches are scoped, but a subtle and crucial detail is that a cache also includes an internal version identifier tied to the runner and the actions/cache version itself. If you update the actions/cache from v3 to v4, the internal version changes, making older caches effectively invisible to the new action. This is a frequent source of cache misses.
The first and most critical step in your debugging journey is to enable the secret, detailed logging that GitHub Actions normally hides from you. There are two primary levels of debug logging you need to know about.
Once you have mastered debugging, the next step is to design your caching strategy to prevent issues from arising in the first place. Adhering to a few key practices will save you countless hours of troubleshooting. debug-action-cache
Now, the cache action will output:
Next time you see Cache restored from key and suspect something is off, remember the steps: turn on debug logs, check the UI, split restore/save actions, and inspect sizes. Master debug-action-cache , and you master GitHub Actions performance.
You can pass these to a script that queries or even downloads cache metadata. Example debug step: gh api -H "Accept: application/vnd
- name: Restore cache id: cache-restore uses: actions/cache/restore@v3 with: path: vendor/bundle key: $ runner.os -gems-$ hashFiles('Gemfile.lock') restore-keys: $ runner.os -gems-
This isolates the save logic, allowing you to see errors like Cache size of 11.2 GB exceeds limit of 10 GB .
: This specific problem was resolved by updating from actions/cache@v3 to v4 or later, as the newer version implemented optimizations to avoid the Node.js bug. Keeping your actions updated is a fundamental best practice. It is also wise to set a segment download timeout, which prevents a stuck download from hanging your job indefinitely. The default is 10 minutes, and you can customize it by setting an environment variable named SEGMENT_DOWNLOAD_TIMEOUT_MINS . This is a frequent source of cache misses
- name: Cache Node Modules uses: actions/cache@v4 with: path: ~/.npm key: $ runner.os -node-$ hashFiles('**/package-lock.json') Use code with caution.
The debug-action-cache is a caching mechanism designed to store the results of expensive computations or actions during the development process. The primary goal is to avoid redundant calculations or operations by quickly retrieving results from a cache, rather than recalculating or re-executing them. This approach can significantly speed up development workflows, especially in scenarios where certain actions or computations are repeated frequently.
Mastering debug-action-cache : How to Troubleshoot and Optimize GitHub Actions Caching