Home >Backend Development >PHP Tutorial >javascript - Why do many websites use another domain name (such as xxstatic.com) to access static resources?

javascript - Why do many websites use another domain name (such as xxstatic.com) to access static resources?

WBOY
WBOYOriginal
2016-08-18 09:16:181213browse

For example, Baidu uses bdstatic.com or bdimg.com to access static resources. Is there any point in doing this? Isn’t it better to go directly to static.baidu.com? Why waste a domain name?

Reply content:

For example, Baidu uses bdstatic.com or bdimg.com to access static resources. Is there any point in doing this? Isn’t it better to go directly to static.baidu.com? Why waste a domain name?

  • Second-level domain names are generally cached by CDN to speed up customer service access.

  • In addition, browsers have limited resources to load a domain name concurrently.

First, in order to prevent domain name cookie scope pollution, needless to say this

The second browser limits the number of concurrent requests in the same domain (6). For example, if there are 10 static resources under a domain name, only 6 will be loaded for the first time, and the other four will be loaded after loading is completed

There are too many things, divided into categories to relieve the pressure on a single server

That’s what I think

I feel like the main domain name has other uses! After all, static files don’t need to look at the domain name!

There is nothing to waste in a domain name. . The most valuable thing is the server. .

The browser has a limit on the number of concurrent users for the same domain name. Different browsers are different. Too many resources will cause congestion and slow loading.
In addition, generally static resources will be provided with CDN to facilitate management.

The two domain names of Baidu you gave as an example may also be due to historical reasons, or multiple domain names are used between different teams

There will be many cookies under the main domain name, which will be brought when making requests. However, these cookies are not needed when requesting static resources, which is a waste of traffic. At the same time, setting up a new domain name is also convenient for CDN caching. There is also the consideration of concurrent browser loading.

Let me talk about the website of my previous unit, where dynamic language and static resources were managed separately (static resources were placed on Qiniu, and the main server was Alibaba Cloud). There are following reasons

  1. Reduced costs, the price of storing static resources is cheaper than that of dynamic resources.

  2. Reduces the load on the dynamic language server. The server that stores the dynamic language may also run other programs, not just this website.

  3. That’s the one upstairs, which improves the efficiency of users accessing the website.

  4. It is also fault-tolerant. If the main server is paralyzed, static resources can still be loaded, so everything is not in vain.

  5. ...It’s all upstairs.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn