← sources

The cache bug that let one customer see another customer's search results

source: reddit (reddit:SaaS)published 2026-07-27 08:43ingested 2026-07-27 09:54

retained text

<!-- SC_OFF --><div class="md"><p>We had a shared cache layer for search results in our backend. It worked fine for months, until a support ticket came in that made no sense: a customer swore they briefly saw someone else's search results before the page &quot;fixed itself.&quot;</p> <p>Turns out the cache key we built didn't include every dimension that made a request unique. We were hashing on query plus account tier, but not on the account's actual data scope. Two customers on the same tier making similarly-shaped queries could, in a narrow window, get served each other's cached response.</p> <p>Nobody had touched the caching code in months. It &quot;worked&quot; because most cache keys happened to collide safely, same query, same result, no harm done. The bug only surfaced once two customers' underlying data actually diverged in a way that mattered.</p> <p>The fix itself was almost boring: add every parameter that scopes the result set into the cache key, even the ones that feel redundant, and write a test that fails if two different accounts can ever produce the same key. The more useful change was upstream of the code, we started treating &quot;what actually varies this result&quot; as a design question to answer before writing a cache layer, not something to patch after a scare.</p> <p>I run engineering at a small backend shop (Edilec) and this is the kind of bug that's cheap to prevent and expensive to explain to a customer after the fact. Curious if others have hit this class of bug, cache correctness seems like one of those things that's easy to get mostly right and still get badly wrong.</p> </div><!-- SC_ON --> &#32; submitted by &#32; <a href="https://www.reddit.com/user/KrishnamMurarka"> /u/KrishnamMurarka </a> <br /> <span><a href="https://www.reddit.com/r/SaaS/comments/1v7umtg/the_cache_bug_that_let_one_customer_see_another/">[link]</a></span> &#32; <span><a href="https://www.reddit.com/r/SaaS/comments/1v7umtg/the_cache_bug_that_let_one_customer_see_another/">[comments]</a></span>

document fetched 2026-07-27 09:54 · canonical https://reddit.com/r/SaaS/comments/1v7umtg/the_cache_bug_that_let_one_customer_see_another