GitHub Actions cache: keys and restore behavior
Cache identity
Cache keys describe compatibility. For a Node project, those can include the runner OS and the lockfile hash. If the lockfile changes while the key stays fixed, inspect whether the restored files still match the installation the job requires.
GitHub’s caching reference distinguishes an exact key hit from a fallback restored through restore-keys. A fallback can save work while still requiring the package manager to complete the installation, and because cache contents can be missing altogether, the job must remain able to recreate them.
Release evidence
A cache is not the release package handed to a deployment job. Keep the build output in a named artifact, and retain evidence about the commit that produced it.
The local cache exercises model keys and fixture content. They do not benchmark package downloads, reproduce remote eviction or prove that cached files are safe. Keep credentials and other sensitive files outside cache paths.