Debug-action-cache -
In this 2,500+ word guide, we will dissect the anatomy of action caching, explore why debugging is necessary, and provide a step-by-step playbook to master debug-action-cache . Before we debug, we must understand the problem. GitHub Actions cache is an immutable blob storage system. You write a cache using actions/cache@v3 or v4 , and later, you attempt to restore it using a key.
However, the fundamentals remain: You cannot optimize what you cannot measure. Until GitHub provides a full Cache UI with version history, manual debugging using ACTIONS_STEP_DEBUG remains the most powerful tool in your DevOps arsenal. The debug-action-cache technique is not about memorizing YAML syntax. It is about visibility . The silent restore, the missing package, the 10-minute delay—all of these yield to the developer willing to flip the debug switch. debug-action-cache
- name: Cache Node Modules uses: actions/cache@v4 env: CACHE_DEBUG: true with: path: node_modules key: $ runner.os -node-$ hashFiles('package-lock.json') V4 debug logs include timing metrics: In this 2,500+ word guide, we will dissect
[debug] Compressing 1,234 files (245MB) [debug] Archive segmented into 3 parts [debug] Uploading part 1/3... If you see a segmentation error (e.g., Part 2 failed to upload ), you have a network issue or a file that changed during compression (race condition). A common mistake is mis-specifying the path . The debug log will show exactly what is being archived: You write a cache using actions/cache@v3 or v4
Combine this with debug-action-cache logs from the workflow run (download the raw logs). Match the cacheKey from the API with the Cache restored from key in the logs. If the last_accessed_at is older than your run, your restore key is wrong. Don't wait for the cache to break. Create a dedicated "Cache Debug" workflow in your repo ( .github/workflows/cache-debug.yml ):
[debug] restoreKeys: [ 'Linux-pip-', 'Linux-' ] [debug] GET response for key 'Linux-pip-main-2d711b': 404 [debug] GET response for key 'Linux-pip-': 200 (Stored key: 'Linux-pip-staging-9c4a7b') Your hashFiles('requirements.txt') changed (maybe a whitespace change), causing the exact key to miss. The restore key Linux-pip- matched a cache from the staging branch instead of main . Step 3: Inspect Archive Contents (The Nuclear Option) Sometimes, cache restoration succeeds, but the data is wrong. The debug-action-cache logs won't show file contents. You need to manually inspect.