A cache key identifies the stored cache entry that a GitHub Actions request retrieves or replaces. Make it specific enough to avoid reusing stale dependencies or artifacts, commonly by combining the runner operating system with a lockfile hash. When the hash changes, the cache no longer matches. section 12.3.2 section 8.4.2
NuGet dependency cache
Configure the cache path, construct a key from the runner operating system and packages.lock.json contents, and provide an operating-system-specific restore prefix: - uses: actions/cache@v3 with: path: ~/.nuget/packages key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} restore-keys: | ${{ runner.os }}-nuget- The hashFiles function computes SHA-256 values for matching files and combines them into one hash. Identical lockfile contents select the existing cache; changed contents produce a different key. section 12.3.2
Apply cache keys with these operational considerations:
- Share a key between jobs when later jobs can reuse cached artifacts produced during continuous integration. section 8.4.2
- Track storage usage and retention costs, especially for container-image caches, which can require considerable storage. section 12.3.2


