Distributed Caching

Caching Strategies

Caching Strategy for restful API and website performance of any web page is a significant factor. It can affect the user’s experience and affect the business if not considered and optimized correctly.

Cache Consistency – Cache Writing Policy

When writing we must decide when to write to the cache or the primary data store.

The following are Cache Writing Policy designs:

Write-behind cache design

This writes first to the cache and then to the primary database which can happen almost immediately or after a set amount of time. Changes in the cache that have not been made to the database are referred to as “dirty”.

Write-behind caching is convenient when you expect to have a write-heavy workload. However, if the time limit is long and the system goes down, you risk losing data that has not been updated in the database.

Write-through cache Design

This updates both the cache and the database at the same time. If the cache layer fails, the update will not be lost since it will be persisted in the database. Write-through caches are convenient when updates are done infrequently. If you perform updates too many times, this reduces the benefit of having a cache in the first place since you must hit the database.

Whenever you're ready

There are 4 ways we can help you become a great backend engineer:

The MB Platform

Join 1000+ backend engineers learning backend engineering. Build real-world backend projects, learn from expert-vetted courses and roadmaps, track your learnings and set schedules, and solve backend engineering tasks, exercises, and challenges.

The MB Academy

The “MB Academy” is a 6-month intensive Advanced Backend Engineering BootCamp to produce great backend engineers.

Join Backend Weekly

If you like post like this, you will absolutely enjoy our exclusive weekly newsletter, Sharing exclusive backend engineering resources to help you become a great Backend Engineer.

Get Backend Jobs

Find over 2,000+ Tailored International Remote Backend Jobs or Reach 50,000+ backend engineers on the #1 Backend Engineering Job Board