Skip to main content

What is DNS cache?

DNS cache is a temporary store of DNS query results, holding the mapping of domain name -> IP address, so that DNS does not need to be queried again every time.

In simpler terms: DNS cache is the "memory" where the computer and DNS servers remember DNS answers.


Why DNS cache is needed

Without a cache, every time a site was opened, it would be necessary to:

  • ask the DNS server again
  • wait for the answer
  • create unnecessary load on the network

DNS cache makes it possible to:

  • open sites faster
  • reduce the number of DNS queries
  • lower the load on DNS servers

Where DNS cache exists

DNS cache exists at several levels:

1. In the browser

  • the fastest
  • used for repeated visits to sites

2. In the operating system

  • shared by all applications
  • used by browsers, programs, services

3. At the provider's DNS server

  • serves thousands of users
  • significantly speeds up access to popular sites

The same domain can be cached in several places at once.


How DNS cache works (step by step)

  1. You open the site example.com
  2. DNS gets the IP address
  3. The answer is stored in DNS cache
  4. As long as TTL has not expired:
  • the cache is used
  • DNS servers are not queried
  1. TTL expires -> the cache is cleared -> the request goes out again

The relationship between DNS cache and TTL

  • TTL determines how long a record stays in cache
  • DNS cache is not permanent
  • after TTL, a record is removed automatically

Possible problems with DNS cache

Sometimes a cache can get in the way:

  • a site moved to a different IP
  • DNS was updated
  • but the cache still holds the old address

In such cases:

  • a site may fail to open
  • it may open an "old version"

The solution is to clear the DNS cache.


Real-life example

DNS cache is like:

  • a saved phone number
  • as long as the number has not changed, you call it right away
  • if the number changed, the record needs to be updated

Short interview answer

Remember this formulation:

DNS cache is a temporary store of DNS answers that allows reusing the mapping between a domain name and an IP address without querying the DNS server again, speeding up network performance.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.