Ray's playground

 

Rule 9: Reduce DNS Lookups(Chapter 9 of High performance Web Sites)

  The Internet is based on finding servers through IP addresses.Because IP addresses
are hard to remember, URLs typically contain hostnames instead, but the IP address
is still necessary for the browser to make its request.That’s the role of the Domain
Name System (DNS).DNS maps hostnames to IP addresses, just as phonebooks
map people’s names to their phone numbers.When you type http://www.yahoo.com/ into
your browser, a DNS resolver is contacted by the browser and returns that server’s IP
address.
  This explanation highlights another benefit of DNS—a layer of indirection between
URLs and the actual servers that host them.If a server is replaced with one that has a
different IP address, DNS allows users to use the same hostname to connect to the
new server.Or, as is the case with http://www.yahoo.com/, multiple IP addresses can be
associated with a hostname, providing a high degree of redundancy for a web site.
However, DNS has a cost.It typically takes 20–120 milliseconds for the browser to
look up the IP address for a given hostname.The browser can’t download anything
from this hostname until the DNS lookup is completed.The response time depends
on the DNS resolver (typically provided by your ISP), the load of requests on it, your
proximity to it, and your bandwidth speed.After reviewing how DNS works from
the browser’s perspective, I’ll describe what you can do to reduce the amount of time
your pages spend doing DNS lookups.

  First, the server has a say in how long records should be cached.The DNS record
returned from a lookup contains a time-to-live (TTL) value.This tells the client how
long the record can be cached.

  Reduce DNS lookups by using Keep-Alive and fewer domains.

posted on 2009-10-20 21:45  Ray Z  阅读(368)  评论(0编辑  收藏  举报

导航