Debug-action-cache !link! [ Top 100 BEST ]
Look for changing environment variables (like PATH or timestamps) that are leaking into the action environment and invalidating the cache. Best Practices for Healthy Action Caching
- name: Generate cache key simulation id: sim run: | echo "hash=$(sha256sum package-lock.json | cut -d' ' -f1)" >> $GITHUB_OUTPUT debug-action-cache
| Symptom | Debug Log Evidence | Fix | | :--- | :--- | :--- | | Cache never restores | GET response: 404 for all keys | Check hashFiles glob pattern. Use ls before cache step to ensure file exists. | | Cache restores empty folder | Path '/cache/node_modules' does not exist | Your path is relative. Use absolute path or $ github.workspace /node_modules . | | Cache upload takes 20 minutes | Compressing 50,000 files | You are caching temporary files (e.g., __pycache__ ). Add !**/__pycache__ to exclude. | | Cache uses too much space | Cache size: 11.2GB (exceeds 10GB limit) | Split cache: One for node_modules , one for build . Use actions/cache/save conditionally. | | Random cache misses | restoreKeys: [ 'Linux-node-' ] matches Linux-node-stable | Make your restore-keys more specific, e.g., $ runner.os -node-$ github.ref - | Look for changing environment variables (like PATH or
You can inspect the state of your caches directly in the GitHub web interface to see their size, creation date, and last access. Navigate to your repository on GitHub. In the left sidebar, click under the "Management" section. | | Cache restores empty folder | Path
The cache action creates a .tar archive. Debug logs reveal segmentation:
debug-cache: runs-on: ubuntu-latest steps: - name: Restore cache debug id: cache-restore uses: actions/cache/restore@v3 with: path: node_modules key: $ runner.os -node-$ hashFiles('package-lock.json') restore-keys: | $ runner.os -node- - name: Show cache status run: | echo "Cache hit: $ steps.cache-restore.outputs.cache-hit " if [ -d node_modules ]; then ls -la node_modules; fi
key: my-cache-$ runner.os -$ github.run_id