DNS lookups are slow when they have to traverse the full hierarchy (root → TLD → authoritative). Without caching, every page visit would require this full lookup, adding significant latency to every connection.
DNS caching stores resolved domain-to-IP mappings at multiple levels (browser, OS, router, ISP) so that subsequent requests for the same domain don’t need to repeat the full lookup process.
Each level maintains a cache with TTL-based expiry:
- Browser Cache: Chrome/Firefox cache DNS for minutes to hours
- OS Cache: Windows/Linux/macOS cache via DNS client service
- Router Cache: Home/office routers cache for the local network
- ISP Cache: ISP recursive resolvers cache for many users
When a request comes in:
- Check each cache in order
- If found (cache hit), return the IP immediately
- If not found (cache miss), continue to next level
- TTL (Time To Live) determines how long entries remain valid
- TTL (Time To Live) controls cache duration in seconds
- Each level can serve the cached result to speed up lookup
- Clearing cache forces a fresh lookup (useful for debugging)
- Cache poisoning is a security risk—false entries redirect traffic
- Built from: DNS Lookup — caching is part of the lookup process
- Related: Recursive DNS — fallback when caches miss
- Related: DNS Hierarchy — caches store results from hierarchical queries
- Contrasts with: DNS Lookup — lookup is the full process; cache is just one optimization
- Stale cache entries point to old/incorrect IPs after server changes
- TTL too long = slow propagation of DNS changes
- TTL too short = unnecessary load on DNS servers
ipconfig /flushdnsclears Windows DNS cache