query keys
A query key identifies cached data and the inputs that distinguish it.
Use this when Changing a filter shows data from the previous selection.
without the term
“When I switch projects, it shows the old project's tasks for a second, or sometimes keeps showing them. I think the cache doesn't know the project changed. Can you fix the caching?”
with the term · How do you ask a model for query keys?
Define query keys for this resource and its filters. Verify different inputs have separate cache entries and equivalent reads reuse one entry.
What is query keys?
The key names a cached result and every input that changes it, such as resource, id, filters, and user. Equivalent reads share a key, and different data must never share one.
Why does query keys matter when vibe coding?
The fetch function can close over an input omitted from the cache key.
How do you do query keys?
Include the relevant resource identity and parameters, with deliberate authorization scoping.
What goes wrong with query keys?
Omitting tenant or user context from a cache whose results depend on it.