up:: [[Computing MOC]]
tags:: #note/develop #on/computing/caching
# Caching
Caching is a computing technique in which a copy of frequently-accessed data is temporarily stored somewhere other than its primary storage. This temporary storage is usually faster to access and reduces the need to constantly fetch from the original, slower data source.
Caching often improves performance by reducing latency, decreasing network traffic, and reducing the load on servers/databases. Most caching locations are much smaller than primary storage, so the trade-off is space vs. speed.
## Use Cases
Caching is used in many different areas of technology, including:
- Operating systems
- CDNs
- Web applications
- Databases
- DNS servers
## Benefits
The act of caching data often results in performance gains for data retrieval. It also brings improved application performance due to memory being faster to access than disks. Other benefits include predictable performance, increased read throughput, and reduced database costs.
## Caching Locations
Cached data can be stored in memory directly or in an in-memory engine such as [Redis](https://redis.io/).
## Best Practices
- Understand the validity of the data being cached
- Use TTLs to expire cached data
- Consider whether High Availability is needed
- Define a Recovery Time Objective (RTO): time it takes to recover from an outage
- Define a Recovery Point Objective (RPO): the last point or transaction captured in the recovery
## Server-side Caching
Server-side caching improves application performance by storing data in memory on the server. This reduces the load on databases and other backend services.
It is common to cache data such as database query results, HTML fragments, and API responses.
## References
“What Is Caching and How It Works | AWS,” Amazon Web Services, Inc., accessed October 18, 2024, https://aws.amazon.com/caching/.
---
> [!createdat] Created at: [[2024-10-18]]