What is Caching?
Why should your application query the database every single time for data that rarely changes?
That's where caching comes in.
Caching means temporarily storing frequently used data so it can be accessed faster.
Without caching:
User → API → Database → Response
Every request hits the database.
With caching:
User → API → Cache → Response
If the data is already in the cache, the application can return it without querying the database again.
Example
Imagine your application has a list of popular products.
Instead of repeatedly asking PostgreSQL for the same products, you could store them temporarily in Redis.
Benefits
Faster responses
Fewer database queries
Better performance under load
Remember
Caching = keeping frequently needed data somewhere faster to access.
Image failed to load.