Overview of OpenFGA Caching Types
mainOpenFGA uses several complementary in-memory caching mechanisms to improve performance and reduce database load:
- Check Query Cache: Caches results of sub-problems within
CheckAPI requests to avoid recomputation. - Check Iterator Cache: Caches database query results (iterators) used during
Checkoperations. - List Objects Iterator Cache: Caches database query results (iterators) used during
List Objectsrequests. - Cache Controller: A background process that periodically invalidates cache entries based on recent writes to the store.
- Authorization Model & Typesystem Cache: Always-on caches for authorization models and their compiled typesystems.
Important Considerations:
- Consistency Bypass: If a request specifies the
HIGHER_CONSISTENCYconsistency preference, all caches are bypassed except for the Authorization Model and Typesystem caches. - Replica Isolation: Caches are in-memory and not shared between service replicas. Effectiveness depends on request patterns hitting the same replica.