What is caching?
A fast, nearby copy of data that's slow or expensive to get.
Why does a website load slowly the first time, and almost instantly the second? Caching.
What it is
A cache is a fast, nearby copy of data that's slow or expensive to get. Instead of doing the work again, you reuse the answer.
How it works
When a request comes in, check the cache first. If the answer is there, that's a cache hit, and you're done. If not, it's a miss: do the slow work, then save the answer in the cache for next time. Caches live everywhere: in your browser, on servers, and in memory stores like Redis.
Why it matters
It makes apps faster and cheaper to run. The catch is staleness: when the real data changes, the cached copy has to be updated or thrown away.










