DNS Caching and TTL Explained
- Networking Fundamentals & OSI Model
- TCP/IP Model
- Network Topologies
- IP Addressing & Subnetting
- Routing Algorithms & Protocols
- Switching Concepts
- Transport Layer Protocols (TCP & UDP)
- Application Layer Protocols
- Network Security & Firewalls
- Wireless Networking & Wi-Fi
- Network Address Translation (NAT)
- DNS Deep Dive
- Congestion Control & Flow Control
- Error Detection & Correction
- Network Devices
- VPN & Tunneling
- Load Balancing & CDN Networking
- Socket Programming
- Network Troubleshooting Tools
- Physical Layer & Transmission Media
- Data Link Layer & MAC Addressing
- Ethernet Protocol
- ARP (Address Resolution Protocol)
- ICMP Protocol
- Unicast, Multicast, Broadcast and Anycast
- Proxy Servers
- Port Numbers Reference
- Network Performance Metrics
- Quality of Service (QoS)
- Software-Defined Networking (SDN)
- HTTP/2 and HTTP/3 Overview
- 5G and Mobile Networks
- IoT Networking Basics
- VoIP Networking Basics
Why DNS Relies Heavily on Caching
Repeating the full multi-step resolution process (covered in the resolution-process note) for every single request to a popular website would be incredibly wasteful. Caching stores previous answers so repeat lookups can be answered almost instantly, without redoing all that work.
TTL: How Long a Cached Answer Stays Valid
Every DNS record includes a TTL (Time To Live) value, measured in seconds, which tells any resolver caching that answer exactly how long it's allowed to keep using it before it must ask again.
example.com. A 93.184.216.34 TTL: 3600 (valid for 1 hour)The Trade-off Between a High and Low TTL
| Long TTL | Short TTL | |
|---|---|---|
| Performance | Faster - fewer repeat lookups needed | Slightly slower - more frequent lookups |
| Update speed | Slow - old cached answers linger longer if changed | Fast - changes propagate to resolvers quickly |
Why Administrators Lower TTL Before a Planned Change
Before migrating a website to a new server (and therefore a new IP address), it's common practice to lower a domain's TTL well in advance. This ensures that once the actual change happens, cached resolvers worldwide will refresh their answer quickly, instead of some visitors being stuck reaching the old server for hours.
Caching Happens at Several Levels at Once
A single lookup can be cached at the operating system level, inside the web browser itself, and at the ISP's resolver - meaning a DNS change can sometimes appear to "not have taken effect yet" for some users purely because one of these several cache layers hasn't expired yet, even though the actual DNS records were updated correctly.