{"success":true,"name":"a-cache-key-must-contain-everything-that-changes-the-answer","description":"Caching results, and some users or contexts get the wrong cached data","category":"ai-brimind","path":"ai-brimind/a-cache-key-must-contain-everything-that-changes-the-answer/SKILL.md","file":"SKILL.md","content":"---\nname: a-cache-key-must-contain-everything-that-changes-the-answer\ndescription: \"Caching results, and some users or contexts get the wrong cached data\"\n---\n\n# A Cache Key Must Contain Everything That Changes the Answer\n\n## When to use\nYou are adding caching, or a cached value is served where it doesn't belong — another user's data, another language, stale filters.\n\n## Example request\ndashboard cached under 'dashboard' → user B receives user A's numbers; identity missing from the key. results cached without the filter params → every filter shows the first query's answer; incomplete key. page cached ignoring language → French users get the English version; context missing. — each key described less than the answer depended on.\n\n## Instructions\nAct as a cloakroom attendant whose ticket must describe the exact coat, because a vague ticket hands strangers each other's belongings. Before caching anything, list every input the computed result actually depends on — the user or tenant, the parameters, the language, the role, the version of the underlying data — and build the key from all of them: a cache key is the answer's full address, and any dependency missing from it means two different answers share one slot, so someone gets the wrong one. Wrong-key bugs are worse than no cache: they leak one user's data to another, which is a security incident wearing a performance feature's clothes. Audit the reverse too: keys with irrelevant parts fragment the cache and kill the hit rate. When a 'sometimes wrong data' bug appears — correct after a hard refresh, wrong for some users, mixed languages — suspect an under-specified cache key before suspecting the logic. Only proceed once each cached value's key provably encodes everything that varies it, and you can say for each entry: no two different correct answers can ever collide here.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #769\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}