Optimize Website Design (9): Reduce the number of DNS searches

Source: Internet
Author: User
Preface

The optimization of website design is a big topic. There are some general principles and some suggestions for different development platforms. This research has never been stopped, and I have shared this topic on different occasions.

As a general principle, Yahoo's team of engineers once provided 35 best practices. For this list, see

Best practices for speeding up your web site http://developer.yahoo.com/performance/rules.html

At the same time, they also released a corresponding test tool yslow http://developer.yahoo.com/yslow/

I strongly recommend that all website developers learn these best practices and apply them based on their actual projects.

In the next period of time, I will combine the ASP. NET development platform and use a seriesArticleTo help you better understand and use these principles.

Preparations

Prepare the following development environment and tools to follow me for subsequent learning.

    1. Google Chrome or Firefox, and install the yslow extension component. Please note that this component is provided by Yahoo, but there is no version for IE currently.
      1. Https://chrome.google.com/webstore/detail/yslow/ninejjcohidippngpapiilnmkgllmakh

        Technorati tags: performance, web design, ASP. NET

      2. Https://addons.mozilla.org/en-US/firefox/addon/yslow/
      3. You should have some knowledge about the developer tools of these browsers. You can call up this tool by pressing F12.
    2. VISAUL studio 2010 SP1 or later, Visual Studio 2012 is recommended
      1. Http://www.microsoft.com/visualstudio/eng/downloads
    3. You need to have a good understanding of the basic development process and core technologies of ASP. NET. This series of articles is difficult to popularize basic knowledge.
Topics to be discussed in this article

In this article, I will discuss the ninth principle: Reduce DNS lookups (reduce the number of DNS searches ).

DNS lookup is a relatively underlying behavior, we enter an address in the browser, such as http://www.cnblogs.com, our browser should be able to correctly locate the blog garden server, the domain name must be resolved. Obviously, it cannot be resolved by itself, so it needs to be searched through a certain mechanism, this is why we usually need to set up a DNS server before going online.

It takes at least 20 milliseconds to search for DNS. During this period, the browser cannot download any other content resources. Therefore, the browser will find a way to cache the DNS search results. In addition to the browser cache, the operating system (such as Windows) also caches the DNS query results. However, because browsers are used too frequentlyMainstream browsers use their own caches instead of operating system caches..

    1. In IE, DNS is cached for 30 minutes by default. For more information about configuration, read this article.
    • Earlier versions were set to one day, which is consistent with Windows Settings.
    • You can use the ipconfig/displaydns command to view Windows DNS cache.
  • Firefox's default DNS Cache Time is said to be 1 minute. If you are not satisfied with this option, you can directly modify network. dnscacheexpiration.
  • Google Chrome's default DNS cache time is also 1 minute. You can view it through chrome: // net-internals/# DNS.
  •  

    We can see that even for browsers, they are also different in the cache DNS (mainly reflected in time). What are the considerations for this difference?

      1. The cache takes a long time to reuse the DNS Cache and increase the speed.
      2. If the cache time is short, the IP address of the target site is detected in time for correct access.

    Therefore, both have their own advantages and considerations.

    So, after talking so much about it, what is the only inspiration for our website design and optimization?

      1. Because DNS lookup takes time, and they are usually only cached for a certain period of time, we should minimize the number of DNS lookup times.
      2. To reduce the number of DNS searches, the best way is to put all the content resources under the same domain. In this way, you only need to perform DNS searches once to access the entire website, this improves the performance.
      3. However, the ideal is always ideal. The above ideal practice will bring about another problem because these resources are in the same domain, in HTTP/1.1, it is recommended that the client only has a certain number of parallel degrees for each domain (it is recommended that 2), so the queuing phenomenon occurs when resources are downloaded, which will reduce the performance.
      4. Therefore, we recommend that youA website uses at least 2 domains, but no more than 4 DomainsTo provide resources. I think this suggestion is reasonable and worthy of our application in project practice.

    At last, let's take a look at the design of the blog homepage in this regard.

    We can see that there will be 47 requests when loading the Home Page. These requests are distributed across different hosts. After deduplication, the following 11 hosts are available. The first five are related to the blog park itself, and the last six are related to advertisements.

    Www.cnblogs.com
    Common.cnblogs.com
    Static.cnblogs.com
    Pic.cnitblog.com
    Passport.cnblogs.com
    Www.google-analytics.com
    Partner.googleadservices.com
    Pubads.g.doubleclick.net
    Static.googleadsserving.cn
    Csi.gstatic.com
    P4-gg6ayhm2r5hvm-ukushuadvfiqpnzm-if-v6exp3-v4.metric.gstatic.com

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.