---
description: >-
  Caches store copies of files in order to deliver them more quickly where they
  are needed.
---

# Caching

Caching is the process of storing copies of files in a cache, or temporary storage location, so that they can be accessed more quickly.

Web browsers cache HTML files, JavaScript, and images in order to load websites more quickly, while [DNS](https://www.cloudflare.com/learning/dns/what-is-dns/) servers cache [DNS records](https://www.cloudflare.com/learning/dns/dns-records/) for faster lookups and [CDN](https://www.cloudflare.com/learning/cdn/what-is-a-cdn/) servers cache content to reduce [latency](https://www.cloudflare.com/learning/performance/glossary/what-is-latency/).

### Browser Caching

Every time a user loads a webpage, their browser has to download quite a lot of data in order to display that webpage. To shorten [page load times](https://www.cloudflare.com/learning/performance/speed-up-a-website/), browsers cache most of the content that appears on the webpage, saving a copy of the webpage's content on the device’s hard drive. This way, the next time the user loads the page, most of the content is already stored locally and the page will load much more quickly.

Browsers store these files until their [time to live (TTL)](https://www.cloudflare.com/learning/cdn/glossary/time-to-live-ttl/) expires or until the hard drive cache is full. (TTL is an indication of how long content should be cached.) Users can also clear their browser cache if desired.

### CDN Caching

A CDN, or content delivery network, caches content (such as images, videos, or webpages) in proxy servers that are located closer to end users than [origin servers](https://www.cloudflare.com/learning/cdn/glossary/origin-server/). (A proxy server is a server that receives requests from [clients](https://www.cloudflare.com/learning/serverless/glossary/client-side-vs-server-side/) and passes them along to other servers.) Because the servers are closer to the user making the request, a CDN is able to deliver content more quickly.

When a user requests content from a website using a CDN, the CDN fetches that content from an origin server, and then saves a copy of the content for future requests. Cached content remains in the CDN cache as long as users continue to request it.

A [cache hit](https://www.cloudflare.com/learning/cdn/what-is-a-cache-hit-ratio/) is when a client device makes a request to the cache for content, and the cache has that content saved. A cache miss occurs when the cache does not have the requested content.

### **DNS Caching**

**DNS caching** takes place on DNS servers. The servers store recent DNS lookups in their cache so that they do not have to query nameservers and can instantly reply with the [IP address](https://www.cloudflare.com/learning/dns/glossary/what-is-my-ip-address/) of a domain.

{% embed url="https://aws.amazon.com/caching/" %}

{% embed url="https://auth0.com/blog/what-is-caching-and-how-it-works/" %}

