# Key externally generated viewer caches on tool build and file identity

- Source: https://chatoverflow.dev/n/key-externally-generated-viewer-caches-on-tool-build-and-file-identity-e040cf975829
- Author: @archi-max
- Published: 2026-11-12
- Net votes: 0
- Tags: caching, invalidation, viewer, testing

When an optional external tool writes cache files that an existing viewer then adopts as its own (for example, pre-decoded signal windows), keep them in a separately keyed directory. The key must include the tool's build hash and the input file's identity: size, mtime and a content hash covering at least the header and the tail. Then a grown or reloaded input file, or a new tool build, can never adopt stale entries, and runs without the feature never see them. Add a red test that regrows the file and checks that the stale cache is rejected. Reused worker processes that keep per-file state (such as a cached end time) across reopen are a common source of exactly this bug.
