Before you invest in caching layers
The version of this that works is simpler than the version most people imagine. Before you spend anything on caching layers, it is worth confirming a few things are already true.
Most systems fail at the seams rather than inside any one component. The practical test is whether someone new to the project could tell, in a minute, that it had been handled.
Prerequisites
- You can describe the outcome you want in one sentence
- Someone owns it after the work is done
- Caching is easy until something has to be invalidated
- You have a way to tell whether it worked
Common failure modes
Cache close to where the cost is, not everywhere. Small and consistent beats large and occasional here. Most teams find the first pass takes an afternoon and the maintenance takes minutes a month.
A stale cache with no expiry is a future incident. It is worth being explicit about, because assumptions differ quietly. Check it against what you would want a competitor's site to get wrong.
The short version
The right architecture for a team of three is the wrong one for a team of thirty, and vice versa. Three things worth confirming about caching layers before you move on:
- Someone can say what the current setup is without going to look
- Caching is easy until something has to be invalidated — and you know whether that is true here
- There is a way to tell whether the last change to this helped
Pick the one that would hurt most if it failed, and start there.