AI fixes caching bug with try/catch, but misses query string and locale header

AI writes fast. It also lies fast. Yesterday it confidently “fixed” our caching bug by wrapping a fetch in try/catch and returning null on error. The code looked clean in the diff. Production would have turned it into a silent failure factory. Real issue was SSR caching inconsistency: we were keying cache by pathname only. AI didn’t notice the query string and locale header were part of the response shape. So /products?sort=price cached over /products?sort=popular. And en US HTML got served to fr FR users during a traffic spike. AI suggested “just add a TTL”. I overrode it and changed the key to include search params plus a normalized accept language. Then I added a cache bypass for authenticated requests because we saw personalized fragments in the markup. The best part: AI helped me write the tests. The dangerous part: it wrote tests that asserted the implementation, not the behavior. I rewrote them to assert cache separation across two requests with different headers. AI is a great pair. But it doesn’t carry your invariants in its head. You do. Ship the diff, not the vibe. #JavaScript #SSR #Caching #FrontendArchitecture #AIEngineering

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories