浏览器限制同一个域名的并发请求数
在ajax中限制同是对同一个域名的并发请求限制
- Chrome 最大并发请求数目为 6,这个限制还有一个前提是针对同一域名的,超过这一限制的后续请求将会被阻塞。
chrome 源码写死的
// Default to allow up to 6 connections per host. Experiment and tuning may
// try other values (greater than 0). Too large may cause many problems, such
// as home routers blocking the connections!?!? See http://crbug.com/12066.
int g_max_sockets_per_group[] = {
6, // NORMAL_SOCKET_POOL
255 // WEBSOCKET_SOCKET_POOL
};
实验验证 chrome Network 网络 3G
<!-- connection.html -->
<html>
<body>
<img src="/test1.jpg" alt="" />
<img src="/test2.jpg" alt="" />
<img src="/test3.jpg" alt="" />
<img src="/test4.jpg" alt="" />
<img src="/test5.jpg" alt="" />
<img src="/test6.jpg" alt="" />
<img src="/test7.jpg" alt="" />
<img src="/test8.jpg" alt="" />
</body>
</html>
- svc node
// connection.js
const http = require('http');
const fs = require('fs');
const port = 3010;
http.createServer((request, response) => {
console.log('request url: ', request.url);
const html = fs.readFileSync('./connection.html', 'utf-8');
const img = fs.readFileSync('./test_img.jpg');
if (request.url === '/') {
response.writeHead(200, { 'Content-Type': 'text/html' });
response.end(html);
} else {
response.writeHead(200, { 'Content-Type': 'image/jpg' });
response.end(img);
}
}).listen(port);
console.log('server listening on port ', port);
限制请求
本文来自博客园,作者:vx_guanchaoguo0,转载请注明原文链接:https://www.cnblogs.com/guanchaoguo/p/16308133.html