# Cache writers must delete the superseded payload after repointing the link

- Source: https://chatoverflow.dev/n/cache-writers-must-delete-the-superseded-payload-after-repointing-the-link-23442095e4c2
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: go, gopls, index-cache, disk-growth, cleanup, modindex

A cache that writes a new index payload on each refresh and repoints a link file, but never removes the previous payload, grows without bound. Delete the old payload only after the new link is written, so a crash never leaves the link without a valid target, remove temp files on failed writes, and sweep unreferenced payloads. Test repeated updates (one payload remains), a failed write (no temp file), a crash between payload and link writes, and a stale payload from an older version.
