Table of Contents

Caching

In the DNS overview, we provided an example of resolving a domain name, and noticed that:

  • To resolve a domain name, we usually need to query multiple authoritative DNS servers, causing the resolving process to take up both time and network resources
  • Along the way, we are obtaining useful information about the structure of the DNS tree

These two factors make it useful to temporarily store the results, both the intermediary delegation information and the final answer, of a query. This is called caching.

Caching is not done on the level of just one PC though: there are special DNS servers outside of the authoritative DNS tree, called caching DNS servers or resolving DNS servers, that do nothing else than accept queries of normal PCs, query the right authoritative DNS servers, and send back the answer. By implementing caching on such as high level, the advantage of caching is very large because information can be re-used many times. Pretty much each Internet provider runs its own caching nameservers for its own clients so that they have a DNS server they can reach quickly and reliably.

The role of caching DNS servers is shown in the following figure:

The PCs in the figure just query the caching DNS server if they want to know anything (and quite rightly, too, I should say). They expect to get a direct answer from the DNS server they query, and will give back an error when they do not get a direct answer. Because this can hardly be called real resolving, normal PCs are usually said to have stub resolvers.

Forwarding

Even though the caching DNS servers your ISP provides are usually quite fast, especially when they can answer directly from their cache, querying them still takes time, and sometimes, depending on your connection speed and DNS server, quite some time, too. So it could be nice to have a DNS server running on your local network, which intercepts the queries and responses from the DNS server of your ISP, and caches them so that it can return them directly the next time. Because the local DNS server doesn’t do any resolving itself, it is called a forwarding DNS server.

This setup is shown in the next figure:

Now, if one’s ISP’s DNS server performs really badly, running a complete caching nameserver is the best option, but in many cases, a simple forwarding DNS server works better because it has the added advantage of using the large collection of cached domain names of the caching DNS server (which presumably also has a quicker Internet connection, causing it to be able to resolve domain names more quickly).

Time To Live (TTL)

All this saving information for later is real nice, but obviously, the internet being a dynamic place and all, you wouldn’t want to save it forever. This is why every Resource record has a so-called Time To Live (TTL), which is the amount of time that a record may be used since it was retrieved from an authoritative DNS server. So it is the administrator of an authoritative DNS server who can control how long a domain name from his domain may be kept.

 
  dns/caching.txt · Last modified: 2005/01/01 15:08
 
Copyright © Meilof Veeningen, 2002-2005 - About Posadis.org