简体   繁体   English

http2最大并发流

[英]http2 max concurrent streams

I'm a noob about http2 but I think that my issue is related to this. 我是关于http2的菜鸟,但我认为我的问题与此有关。 First of all I have this wordpress website https://anekitalia.com that is hosted in my company huge cluster. 首先,我有这个wordpress网站https://anekitalia.com ,它托管在我公司庞大的集群中。 This is an lxc debian9 container with lamp and http2 mod enabled and I'm using the caching plugin wp rocket. 这是一个lxc debian9容器,启用了灯和http2 mod,我正在使用缓存插件wp rocket。 In the home page I have placed two javascripts to randomize the background video and background image(image is visible only on mobile devices). 在主页中,我放置了两个javascripts来随机化背景视频和背景图像(图像仅在移动设备上可见)。 This is the code that I'm using. 这是我正在使用的代码。

<script>
//random video only desktop
var isMobile = 
/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ? 
true : false;
jQuery(document).ready(function($){
  if(!isMobile) {
        var video = new Array ();
        video[0] = "/anek-ferry-traghetti-grecia-low.mp4";
        video[1] = "/anek-ferry-traghetti-grecia-v2-low.mp4";
        var randomvideo = Math.floor(Math.random() * video.length);
        $('#random-clip video').attr('src', '/wp-        
 content/uploads/media' + video[randomvideo]);
        $('#random-clip source').attr('src', '/wp- 
content/uploads/media' + video[randomvideo]);
    }
});
</script>
<script>
//random background only mobile
jQuery(document).ready(function($){

 var background = new Array ();
 background[0] = "/traghetti-italia-grecia-anek-fallback1.jpg";
 background[1] = "/traghetti-italia-grecia-anek-fallback5.jpg";
 background[2] = "/traghetti-italia-grecia-anek-fallback2.jpg";
 var randombackground = Math.floor(Math.random() * background.length); 

$("#random-clip.et_pb_fullwidth_header.et_pb_fullwidth_header_0").css({
  'background-image': 'url(/wp-content/uploads/media' + 
background[randombackground] + ')',
    'background-position-y': '35%' });
});
</script>

problem is that if you delete your chrome cache and look at the waterfool, you will notice this 问题是如果你删除你的chrome缓存并查看waterfool,你会注意到这一点 瀑布 the request for background video anek-ferry-traghetti-grecia-v2-low.mp4 starts together with the facebook pixel and google scripts, but stops and then restarts after a little, then stops again and restarts, after that the request for the random background starts. 请求背景视频anek-ferry-traghetti-grecia-v2-low.mp4与facebook像素和google脚本一起启动,但停止然后重新启动一点,然后再次停止并重新启动,之后随机请求背景开始。 what I'm expecting with http2 is that all requests starts near each other, I cannot understand this fragmentation, so I think that when all the google and facebook scripts starts, they overload the maximux stream request and this is the result. 我对http2的期望是所有请求都是彼此靠近开始的,我无法理解这种碎片,所以我认为当所有google和facebook脚本启动时,它们会重载maximux流请求,这就是结果。 I read that I can increase a settings SETTINGS_MAX_CONCURRENT_STREAMS that maybe can fix this, but as I wrote I'm noob with http2 so I have no idea where to place this directive. 我读到我可以增加设置SETTINGS_MAX_CONCURRENT_STREAMS,这可能可以解决这个问题,但正如我写的那样,我是noob with http2所以我不知道在哪里放置这个指令。 Hope that someone can at least point me to a direction. 希望有人能够至少指出我的方向。 many thanks 非常感谢

The reason your image is requested 3 times is not because of HTTP/2 max concurrent streams (there are not that many in your screenshot), but because the image is downloaded in parts - this is evident from the response status code 206. 您的图像被请求3次的原因不是因为HTTP / 2最大并发流(屏幕截图中没有那么多),而是因为图像是按部分下载的 - 这从响应状态代码206中可以看出。

You can read more about the 206 status here: https://httpstatuses.com/206 . 您可以在此处阅读有关206状态的更多信息: https//httpstatuses.com/206

What you see is perfectly normal behavior. 你看到的是完全正常的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM