Caching Strategies
Published on: 06 September 2025
Read-intensive application caching strategies
Cache-aside
sequenceDiagram
participant App
participant Cache
participant DataStore
App->>Cache: 1. Read from cache
Cache-->>App: Cache Miss
App->>DataStore: 2. Read from data store
DataStore-->>App: Data
App->>Cache: 3. Store in cache
App->>App: 4. Return to app
Read-through
sequenceDiagram
participant App
participant Cache
participant DataStore
App->>Cache: 1. Read from cache
Cache->>DataStore: 2. Read from data store, if not in cache
DataStore-->>Cache: Data
Cache->>Cache: 3. Store in cache
Cache-->>App: 4. Return to app
Refresh-ahead
sequenceDiagram
participant App
participant Cache
participant DataStore
App->>Cache: 1. Read from cache
Cache-->>App: Return stale data
Cache->>DataStore: 2. Read from data store (asynchronously)
DataStore-->>Cache: Fresher data
Cache->>Cache: Update cache
Write-intensive application caching strategies
Write-through
sequenceDiagram
participant App
participant Cache
participant DataStore
App->>Cache: 1. Write to cache
Cache->>DataStore: 2. Write to data store
DataStore-->>Cache: Ack
Cache-->>App: Ack
Write-around
sequenceDiagram
participant App
participant DataStore
participant Cache
App->>DataStore: 1. Write to data store
DataStore-->>Cache: 2. Async write to cache
DataStore-->>App: Ack
Write-back
sequenceDiagram
participant App
participant Cache
participant DataStore
App->>Cache: 1. Multiple writes to cache
Cache-->>App: Ack
Cache-->>DataStore: 2. Async write to data store