DNS lookup, domain name, and Cookies_ Web application
Source: Internet
Author: User
My website domain name is www.yining.org, have a page (for example on this blog entry) with a picture, its src is:/img/camel.gif, then its URL is: "Http://www.yining.org/img/camel.gif". If the page has a cookie set (for example, to record the message's ID and website address, etc.), The role of the cookie is automatically www.yining.org, so each time you visit the page, because the URL of the domain name is www.yining.org, then the browser will bring cookies to the picture to initiate a request, even if the web The cache has www.yining.org/img/camel.gif records and is still going to my server (the origin server) instead of returning from the middle of the Web cache- Because requests with cookies may return different response depending on the value of a different cookie.
But this is not ideal for many static resources (images, CSS, and JavaScript), because no matter what cookies are, their response are the same content, and their requests are not necessarily returned to Origin server every time. Second, because different Web cache requests for cookies are different, even some caches can cache response with cookies, but 1 is not the most cache can do this, 2 most cache defaults to caching response without cookies. So the best way is to isolate the static resources using different domain names. Although the path attribute of the cookie can do this, but after all, too many restrictions, rather than using a dedicated domain name flexible.
So should be as far as possible to all static objects and dynamic page domain name separate, more strictly speaking, is not required to read and write the client cookie server resources and need to read and write cookies separate to different domain names. For example, I can set another domain name static.yining.org, in the reference to the image of src attribute to "http://static.yining.org/img/camel.gif", then when visiting the home page, Browsers do not carry cookies (because the domain name of the function is now different), which makes better use of Web cache caching and server performance. I consulted a classmate who once worked for Netappliance, the largest web cache maker, according to his experience, the difference between band and without cookies is likely to be 20% or greater.
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.