Angular Cache Bug: URL-Only Keys Serve Stale Data After User Context Switch
A common Angular caching bug causes users to see data belonging to a different user, tenant, or permission context after switching accounts. The root cause is an incomplete cache key that relies solely on the API endpoint URL, failing to account for context-specific inputs like tenant ID, locale, or user permissions. When two different contexts request the same endpoint, the cache incorrectly treats them as identical and returns the previously stored response. The fix requires building composite cache keys that include every variable affecting the response, such as context ID and normalized query parameters. Additionally, a context-switch event should explicitly clear cached entries to prevent stale or sensitive data from persisting beyond its valid scope.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in