How does local DNS cache and cache clearing work?


How does local DNS cache and cache clearing work?

In: 5

2 Answers

Anonymous 0 Comments

DNS is basically a phone book for the internet; your computer calls your local DNS server when it wants to know the IP address of a website.

If your local DNS server (“local” usually meaning your ISP, but some people run their own DNS servers on their network, or their router stands in as a DNS server, passing requests on to the ISP) doesn’t know the address, it will send the request to another one, and eventually the right server will return the information (or it will say it doesn’t exist).

In order to avoid sending requests and data that isn’t necessary, your computer may “cache”, or store locally, the responses to DNS queries. So when you visit reddit dot com, instead of asking your DNS server for the address and incurring the network overhead, it just looks in the cache and gives the address it already has.

The items in the cache expire eventually, and will be re-queried. If you want to force clearing the DNS cache on your Windows computer, running the command “ipconfig /flushdns” from an elevated command prompt will clear it, so any requests from that point on will be pulled from the server and not the cache.

Sometimes you might want to clear the cache if you know the IP address of a server changed, or if you were having DNS trouble and want to make sure you’re getting the right results. But usually you don’t need to mess with it.

Anonymous 0 Comments

Pretend you just bought some lettuce (your computer did a DNS lookup) and you put it in the fridge (cached the response).

If you are hungry for lettuce (ie/ visit the same website), you go to the fridge for lettuce, not back to the store.

You need to use the lettuce before it goes off (cache time to live (TTL)). If it has gone off, you throw it in the compost (cache expired).

If you suspect the lettuce is bad before the expiry date, you can choose to put it in the compost early (clear the cache) and go back to the store to buy new lettuce (get a fresh DNS lookup response).