Skip to content

5 min read

Finding sites: DNS and caching

From a name to a number

Here is a puzzle. You type an address like a website name, made of words. But packets need a numeric IP address to find their way. So how does the name made of words become a number?

The answer is a system that works like a phonebook for the internet. You know someone's name, and the phonebook gives you their number. In the same way, this system takes the readable name you typed and looks up the matching IP address. Its name is the Domain Name System, usually shortened to DNS.

Without this step, nothing else can happen. The name you type is easy for a person to remember but means nothing to the machines that move your packets. DNS is the translation that turns the name you can read into the number the network can route.

The lookup chain

Looking up the number happens in a short chain of questions, handled by a helper called a resolver:

  • Your computer asks the resolver, "what is the IP address for this name?"
  • The resolver first asks a top-level directory, a root server, "where do I find names with this ending?" and is pointed to the right directory for that ending, for example the one that handles .com or .al.
  • It asks that directory, which points it to the specific servers that know about the exact site.
  • Finally it asks those servers, which return the real IP address.

It sounds like a lot of back and forth, but it happens in a fraction of a second, before the page even begins to load. Only once the resolver hands back that number can your packets be labelled and sent on their way.

Remembering the answer

Asking that whole chain every single time would be wasteful. You visit some sites again and again, and their address rarely changes. So the resolver keeps a copy of answers it has already found, for a while, close at hand.

Storing information in a temporary place so you can fetch it faster next time is called caching. Once the resolver has looked up a name, it remembers the number for a set period. The next time you or a neighbour asks for the same site, the answer comes straight back, with no long chain of questions needed. Your browser and your device do the same, each keeping their own small store. Caching is one of the quiet reasons the web feels quick.

Tip

Caching is a trade. You get speed by trusting a slightly older copy. That is usually fine for a website's address, which rarely changes, and it is why a page sometimes loads an out-of-date version until the stored copy expires.

Check yourself

  • DNS is often compared to a phonebook. What does it actually turn into what, and why is that step needed before your packets can travel?
  • The lookup happens as a short chain of questions handled by a resolver. Roughly what does the resolver ask along that chain, and why does it still finish in a fraction of a second even though it sounds like a lot of back and forth?
  • Caching makes revisiting a site faster, but it means you are trusting a slightly older answer. Why is that trade usually a safe one for a website's address?

Developed by alphaPlan Center.

Found something unclear, outdated or improvable? Suggest an improvement