Home >Web Front-end >HTML Tutorial >Why do many websites put style sheets, pictures and other resources under an independent domain name? _html/css_WEB-ITnose
This problem has troubled me for a long time~~
I have found that more and more large websites like to put images, style sheets, JS and other resources used on web pages under an independent domain name.
What are the benefits of doing this? Can any hero please explain~
For example:
Zhongguancun Online
zol.com.cn
zol-img.com.cn
Maybe to prevent theft
Reduce the pressure on the server, image resources still consume a lot of server resources and bandwidth
This is for server load balancing.
Of course, it is also very convenient to prevent hotlinking, because the server pressure is separated and is relatively small.
The browser has a limit on the number of links for the same domain name
The browser has a limit on the number of links for the same domain name
Who told you! ! ! If you don’t understand, don’t talk nonsense.
Put different resources under different domain names in order to divert the pressure on the server.
You can try to query the IP addresses of those domain names. In this case, multiple servers can be used to serve the website. When the website access pressure is high, multiple servers can bear far more than a single server. The pressure is high.
Quoting the reply from firebugdotname on the 4th floor:
The browser has a limit on the number of links for the same domain name
Who told you! ! ! If you don’t understand, don’t talk nonsense.
Put different resources under different domain names in order to divert the pressure on the server.
You can try to query the IP addresses of those domain names. In this case, multiple servers can be used to serve the website. When the website access pressure is high, multiple servers can bear far more than a single server. The pressure is high.
1
Quoting the reply from firebugdotname on the 4th floor:
The browser has a limit on the number of links for the same domain name
Who told you! ! ! If you don’t understand, don’t talk nonsense.
Put different resources under different domain names in order to divert the pressure on the server.
You can try to query the IP addresses of those domain names. In this case, multiple servers can be used to serve the website. When the website access pressure is high, multiple servers can bear far more than a single server. The pressure is high.
It’s really uncomfortable not to be understood and to be called “nonsense”. Don’t you know on the 5th floor that browsers will maintain a certain number of links for requests for resources in the same domain? Too many requests at the same time (in a very short period of time) will be blocked. If you do ajax, you know this. Please don’t mislead me. Of course, I don't object to what you said about offloading the pressure on the server.
Who knows if the two domain names point to the same server?
It’s really uncomfortable not to be understood and to be called “nonsense”. Don’t you know on the 5th floor that browsers will maintain a certain number of links for requests for resources in the same domain? Too many requests at the same time (in a very short period of time) will be blocked. If you do ajax, you know this. Please don’t mislead me. Of course, I don't object to what you said about offloading the pressure on the server.
I understand you
LZ can take a look at the 34 rules of Yahoo front-end optimization
You can also use plug-ins such as YSlow to rate your website
Sometimes even Allocate multiple domain names on the same server for optimization. However, too many domain names may result in too many DNS queries, so this method is often not abused.
Of course, large websites generally enable CDN for static resources such as images and CSS. This is another aspect.
Mainly to improve the performance of the website, placing images, css, and js files on another server (resource server) is beneficial to CPU load and bandwidth balancing. It is inappropriate for the href and src attributes of the HTML tag in the web page to reference an IP address (because the IP address of the resource server may change), so register an independent domain name for the resource server to facilitate the setting of the href and src attributes once and for all.
For example, the website is placed on server A, and the pictures are placed on server B (202.123.16.8). There is a web page in A, and if the src attribute of a certain tag is set to src="202.123.16.8/images/ 1.jpg", if the IP address of B is changed to something else, the website program will run incorrectly. So give B an independent domain name, such as www.ziyuan123456.com, and let this domain name point to 202.123.16.8, then src="http://www.ziyuan123456.com/images/1.jpg" will do. If B's IP address changes in the future, all you need to do is redirect the domain name, and the website program does not need to be changed.
The browser has a limit on the number of links for the same domain name
up~~~~
Reduce the number of http requests and the number of IIS links to ensure that more users can connect at the same time Open pages faster
Don’t you use ajax too much? At the same time, why do you add a very short time? This assumption simply does not exist. When the browser downloads resources, it opens some new threads. If you have done multiple threads, you know that threads cannot be opened infinitely. Does this have anything to do with the number of IIS links? Have you ever seen a browser that is blocked when accessing web pages? Then you have seen service unavailable. This is caused by the high concurrency of the web server. . .
It’s talking about the number of simultaneous requests from the browser, not the server side
Quoting the reply from firebugdotname on the 7th floor:
Quoting the reply from robake on the 5th floor:
Quoting the reply from firebugdotname on the 4th floor:
...
It’s really uncomfortable not being understood and being called “nonsense”. Don’t you know on the 5th floor that the browser is correct? Will requests under the same domain resource maintain a certain number of links? Too many requests at the same time (in a very short period of time) will be blocked. If you do ajax, you know this. Please don’t mislead me. Of course you are talking about the pressure on the offload server...
YES I write too much ajax. Just because you haven’t encountered it doesn’t mean others haven’t encountered it. Suppose I send an ajax request. The server did not respond to me immediately for some reason. At this time, I sent another request, but it still did not respond to me immediately. Such accumulation will cause subsequent requests to be unable to be sent at all. Why did I add "extremely short time"? The server timed out, you know this.
What everyone said is really good. I understand a lot. I will digest it and then come back to post it. Thank you all!
[/url]’s reply:]
Maybe to prevent theft, I agree with this view
Quote from 13th floor robake’s reply:
Quote from 7th floor firebugdotname Reply:
Quote from robake on the 5th floor:
Quote from firebugdotname on the 4th floor:
……
It’s really uncomfortable not to be understood and to be said. It's "nonsense". Don't you know, on the 5th floor, that browsers will maintain a certain number of links for requests for resources in the same domain? Too many requests at the same time (in a very short period of time) will be blocked. If you do ajax, you know...
It seems that you have never done desktop development or multi-threading. , the browser downloads resources through threads, even ajax is also performed by the browser using threads. Too many ajax requests at the same time are blocked not because of your number of links, but because the browser limits the number of threads used by the browser in order to ensure system resources. Too many threads will be consumed. All the resources of the computer cannot cause the system to respond slowly just because a web page is opened. As long as the number of threads limited by the browser is not reached, your ajax request will not be blocked. Do you understand?
At the same time, have you ever seen anyone open dozens of web pages at once? The main purpose of placing different resources on different servers is to divert pressure and facilitate maintenance (especially for websites that use clusters, this plays a very important role in maintenance).
Obviously I have not done desktop development, I have done web development.
One holds a knife and the other holds a sword. How to differentiate between high and low. Fuck
One holds a knife and the other holds a sword. How do you tell the difference? In fact, the issues discussed are all web issues, which are quite different from desktop issues.