A write-around cache strategy is often lauded for its simplicity and the performance gains it offers for read-heavy workloads, but its true power emerges when you understand the precise conditions under which it shouldn’t be used, and why.

Let’s see it in action. Imagine a typical scenario: a user is browsing product listings on an e-commerce site.

{
  "transaction_id": "txn_a1b2c3d4e5f6",
  "timestamp": "2023-10-27T10:30:00Z",
  "operation": "read",
  "resource": "/products/12345",
  "cache_hit": true,
  "latency_ms": 5,
  "data": {
    "id": 12345,
    "name": "Super Widget",
    "price": 99.99,
    "description": "A truly super widget for all your widgeting needs."
  }
}

Here, the request for product 12345 is served directly from the cache, resulting in a lightning-fast 5ms latency. This is the happy path for write-around.

Now, consider a different scenario: a system that frequently updates a small, frequently accessed data set, like a real-time stock ticker or a counter for active users on a dashboard.

{
  "transaction_id": "txn_f6e5d4c3b2a1",
  "timestamp": "2023-10-27T10:31:15Z",
  "operation": "write",
  "resource": "/stock/AAPL",
  "cache_status": "write_through",
  "latency_ms": 20,
  "data": {
    "symbol": "AAPL",
    "price": 172.50,
    "timestamp": "2023-10-27T10:31:14Z"
  }
}

In a write-around cache, when a write operation occurs, the data is written directly to the primary storage (like a database or disk) and bypasses the cache entirely. The cache only gets updated if a subsequent read operation for that same piece of data occurs.

This seems simple, but it creates a critical problem: the cache becomes stale. If the data is frequently updated, the cache will very rarely contain the most current information. Every read operation that should hit the cache will instead miss, forcing a round trip to the slower primary storage. This effectively negates the performance benefits of the cache for frequently modified data.

The core mental model for write-around is: Reads are fast, writes are irrelevant to the cache. It’s designed for scenarios where data is read far more often than it’s written, and when it is written, the old data in the cache is acceptable for a short period. Think of product catalogs, article content, or configuration settings that rarely change.

The levers you control are:

  • Cache Invalidation Strategy: While write-around inherently bypasses the cache on writes, you still need a strategy for when the cache does get populated. This is usually on a cache miss during a read.
  • Cache Eviction Policy: Standard policies like LRU (Least Recently Used) or LFU (Least Frequently Used) still apply to manage cache size.
  • Primary Storage Speed: The effectiveness of write-around is heavily dependent on how fast your primary storage can handle writes. If your primary storage is already slow, bypassing the cache on writes doesn’t gain you much.

The real nuance lies in the "write bypass." When a write occurs, the cache is untouched. The primary storage is updated. It’s only on the next read for that specific item that the cache is checked. If it’s not there (because it was written directly to disk), the read goes to primary storage, retrieves the latest data, and then populates the cache with that new data. This means every write operation, in a sense, guarantees a cache miss on the very next read for that item.

Consider the scenario where your application performs a write operation and then immediately needs to read that same piece of data back. With write-around, this sequence is: write to primary storage, then read from primary storage (because the write bypassed the cache), and then the cache is updated with the data just read. This is much slower than if the write had updated the cache and the subsequent read hit it.

The problem isn’t just stale data; it’s the performance penalty incurred by that staleness. If your workload involves frequent read-after-write patterns for the same data, write-around is actively detrimental. You’re essentially forcing a cache miss and a slower primary storage read when a cache hit would have been possible with a different caching strategy.

The ultimate consequence of using write-around for a write-heavy or read-after-write workload is not just a slightly slower system, but a system that will eventually experience significant read latencies as the cache becomes increasingly irrelevant. You’ll find yourself debugging slow reads that appear to be cache misses, only to realize the cache is perpetually out of sync.

Want structured learning?

Take the full Caching-strategies course →