What is a cache and why can it speed up an application so much?
Published on 2026-10-20 by frfrand
What is a cache, how hit, miss, TTL and invalidation work, where it lives (browser, CDN, Redis or the database) and when it really speeds up a website.

Short answer: A cache is a place where we temporarily store results that we will probably need again. It can speed up a website because it avoids repeating queries, calculations, and downloads every time someone requests the same information.
It's not magic. If your application takes two seconds to calculate a list of products and fifty people request exactly the same list, it might not make sense to do the same work fifty times.
The coffee shop example
Imagine a coffee shop where every customer asks for the menu. The waiter could go down to the stockroom, find the original design, and print a new copy for each table. But the reasonable thing is to have several menus ready.
A cache does something similar. It keeps a copy of certain information to respond faster to future requests.
The problem starts when the menu changes: if you keep old menus, you could show prices that are no longer correct. That is the least fun part of caches: invalidating them properly.
Hit, miss, and TTL: three words you will come across
A cache hit occurs when the requested information is in the cache and can still be used. A cache miss occurs when it is not available or is no longer valid, so the original source must be consulted.
The TTL, or time to live, establishes for how long an entry can be considered valid according to a specific policy.
For example, you could store for five minutes the result of a public categories list. If someone queries it again before it expires, the application can respond using the copy. But a bank account balance requires much more careful handling.
TTL is a tool, not a license to display incorrect data.
Where can caches be?
In the browser: images, fonts, and certain files from a website can be reused without being fully downloaded every time.
In a CDN: copies of resources can be delivered from geographically distributed nodes, close to visitors.
In the application: calculation results or queries can be stored in local memory or in a shared service like Redis.
In the database: different engines keep structures and pages in memory to reduce disk accesses.
These layers do not all work the same way. Nor is it advisable to activate them without knowing what problem you are solving.
How is a cache implemented in an API?
Imagine that an endpoint returns featured products. First you check if there is a valid result with a key like productos:destacados. If you find it, you return it. If not, you query the database, prepare the response, and store the result for a limited time.
The process seems simple until two hundred requests arrive just as the same key expires: they could all try to recalculate at the same time. That phenomenon can overload the origin. For demanding cases there are locking strategies, early renewal, or staggered expirations.
You also shouldn't use the same key for responses that depend on each person's permissions. A bad cache can show private data to someone who shouldn't see it.
What does invalidating the cache mean?
It means marking or deleting copies so that the next requests get new data.
You can do it by time, after a specific event, or through a different version of the key. For example, when updating a product's price you may need to invalidate the catalog cache.
One of the most annoying bugs is the one where the administrator sees the new price but visitors keep seeing the previous one. Often the database isn't failing: someone forgot how the copies are updated.
Does a cache always improve performance?
No. If a query already takes one millisecond, saving and retrieving a copy on another server can add complexity without a real gain. It also consumes memory and forces you to solve consistency, permissions, and cache service failures.
First measure: which operation takes long?, how many times is it repeated?, how long can the information age?, what happens if the cache is lost? Only then choose the strategy.
Where does ArduMaker come in?
At ArduMaker, Redis is installed on your VPS from the app catalog, with a password and a default memory limit of 256 MB; if you enable Internet access, it is encrypted with TLS and limited to an IP allowlist. An application deployed there can use Redis to store temporary results, as long as keys, expirations, and permissions are well designed. To invalidate without showing stale data, see Redis and caching: how to invalidate data. Redis is also used for other purposes, so Redis should not be confused with the general concept of caching.
Frequently asked questions
What is the difference between a cache and a CDN?
A cache is any temporary copy that avoids repeating work. A CDN is a specific type of cache: a network of servers distributed around the world that stores copies of your website's files close to visitors. You can have a cache without a CDN (for example, Redis on your server), and a CDN does not speed up personalized responses from your backend.
What happens if the cache is deleted?
If it is well designed, nothing serious: subsequent requests go to the original source, take a little longer, and refill the cache. The problem arises when the application treats the cache as if it were the database and stores there information that does not exist anywhere else.
To remember: a cache trades repeated work for temporary storage. It works very well when you know what information can be reused and when it must stop being valid.
Sources: HTTP Caching on MDN · Redis Documentation · Article about Redis on ArduMaker.
