Look-Aside vs Inline Cache Topologies
What you'll learn: You'll understand the two fundamental architectural patterns for positioning caches in your system and when to use each.
The Two Cache Positions
When adding a cache layer to your system, you have two fundamental choices about where the cache sits:
Look-Aside (Side Cache)
The application manages the cache directly. The app decides when to check the cache, when to query the database, and when to populate the cache. The cache sits "beside" the data flow path.
Flow:
- App checks cache first
- On miss, app queries database
- App writes result back to cache
- App returns data to user
Analogy: Like keeping a notepad beside your desk. You manually check it, and if the answer isn't there, you walk to the filing cabinet, get the document, then write a note on your pad for next time.
Inline Cache (Cache-Through)
The cache sits between the application and database. The app only talks to the cache layer, which handles all database interactions transparently. The cache intercepts all requests.
Flow:
- App requests data from cache
- Cache checks itself
- On miss, cache queries database automatically
- Cache stores and returns result
Analogy: Like having an assistant who manages the filing cabinet. You always ask them, and they handle checking their notes or retrieving from storage without you knowing.
Key Differences
Look-Aside gives you full control but requires more application code. This is what patterns like Cache-Aside implement.
Inline simplifies application logic but the cache becomes a critical component in the data path (potential bottleneck or failure point).
Key Takeaway: Look-aside lets your app control caching logic explicitly, while inline makes the cache a transparent intermediary—choose based on whether you want flexibility or simplicity.