结合使用HTTP/2和angularJS [英] Using HTTP/2 with angularJS

查看:125
本文介绍了结合使用HTTP/2和angularJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我偶然发现HTTP/2时,我试图找到提高Web应用程序性能的方法.通过阅读它,我知道它具有许多功能可以提高网站性能.

I am trying to find out ways to increase the performance of my web application when I stumbled upon HTTP/2. On reading about it, I got to know that it has very many features to increase website performance.

谈到它的实现部分,我看到您只需要将浏览器升级到最新版本即可使用.由于我的浏览器已经是最新版本,因此我看到所有资源-CSS,JS和HTML文件都通过HTTP/2提供.但是,我使用angularJS进行的数据查询仍然使用HTTP/1.1.这是我的问题.

Coming to the implementation part of it, I see that you only have to upgrade your browser to the latest version for it to come to use. Since my browser is already at the latest version, I see that all of my resources - CSS, JS and HTML files are served with HTTP/2. However, the data queries that I make using angularJS still use HTTP/1.1. Here are my questions.

  1. 如何获取数据查询以使用HTTP/2协议?我必须在标题中添加一个额外的参数吗?

  1. How do I get my data queries to use HTTP/2 protocol? Do I have to add an extra parameter in the header?

HTTP/2会放弃浏览器每个域限制的6个同时请求吗?我可以发出6个以上的并行ajax请求吗?

Will HTTP/2 let go of the 6 simultaneous requests per domain limit of the browsers? Can I make more than 6 parallel ajax requests?

我在客户端使用angularJS.我的请求通过Cloudflare到达了Play框架提供的服务器.

I use angularJS on the client side. My request go through Cloudflare to a server served by Play Framework.

推荐答案

如果客户端(浏览器)和网络服务器均支持HTTP/2,则将使用它.您的前端JavaScript不需要任何区别-浏览器会自动使用它.

If HTTP/2 is supported by both client (browser) and webserver then it will be used. There is no difference needed in your front end JavaScript - the browser will automatically use it if it can.

因此,我想您的数据"查询与常规查询位于不同的域上,并且该域不支持HTTP/2.

So I would guess your "data" queries are on a different domain to your regular queries and that domain does not support HTTP/2.

是的,HTTP/2大大增加了正在运行的并行请求的数量.飞行中的100个流"是一种常见的服务器设置.但是,这确实带来了所有有趣的挑战:例如,Chrome发现在同时发生许多请求的情况下处理某些效率低下,并且一段时间内一次最多只能发送6个HTTP/2请求.同样,一些较低优先级的请求(例如,在折叠图像下方)可以使用更好地用于较高优先级的请求(例如,在折叠图像上方)的带宽. HTTP/2具有依赖项和优先级的概念,但并非每个浏览器都使用它们.

Yes HTTP/2 dramatically increases the number of parallel requests in flight. 100 in flight "streams" is a common server setting. This does however bring all interesting challenges: For example, Chrome found it had some inefficiencies to deal with when having that many requests happening at the same time and for a while there put in a limit of 6 HTTP/2 requests at a time. Also some lower priority requests (e.g. below the fold images) can use of bandwidth better used for higher priority requests (e.g. above the fold images). HTTP/2 has the concept of dependencies and priorities but not every browser uses them.

一旦进入,这将是一个有趣的话题.

It’s a fascinating topic once you get into it.

这篇关于结合使用HTTP/2和angularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆