Why does image server use a new domain name to boost performance?

Source: Internet
Author: User

[ZZ from: http://www.yining.org/2007/08/29/dns-lookup-domain-names-and-cookies/]
Reducing DNS lookup can shorten the page response time, but it is not the best way to reduce DNS lookup to one by using only one domain name for all website resources. This is not only because of the possibility of reduced parallel downloads, but also because the Web cache processes requests with and without cookies and returns differently.

My website domain name is www.yining.org. There is a page (for example, this blog entry) with an image. Its SRC is/img/camel.gif, and its URL is: "http://www.yining.org/img/camel.gif.pdf ". If a cookie is set on this page (for example, to record the message holder's ID and website address), the cookie domain name is automatically www.yining.org. Every time you access this page, because the Domain Name of the URL is www.yining.org, the browser will send a request to the image with a cookie. Even if the Web cache along the way has a record of www.yining.org/img/camel.gif, it will still be sent to the origin server ), instead of returning from the intermediate Web Cache-because requests with cookies may return different response values based on different cookie values.

However, this is not ideal for many static resources (images, CSS, and JavaScript), because no matter what the cookie is, their response contains the same content, there is no need to return to origin server every time for requests. Second, because different Web Cache supports different requests with cookies, even if some cache can cache response with cookies, but 1) not most of the cache can do this, 2) most of the caches default cache response without cookies. Therefore, the best way is to use different domain names to isolate static resources. Although the path attribute of the cookie can also achieve this, there are too many restrictions, so it is better to use specialized domain names flexibly.

Therefore, we should try to separate all static objects from dynamic page domain names. More strictly speaking, the server resources that do not need to read or write client cookies are separated from the programs that need to read or write cookies to different domain names. For example, I can set another domain name static.yining.org and change the src attribute in the referenced in the image to "alias (because the domain name is different now ), in this way, the Web cache and server performance can be better utilized. I have consulted a person who once worked in netappliance (the largest Web Cache vendor). According to his experience, the difference between with and without cookies may be 20% or even greater.

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.