问题
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.
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.
How do I get my data queries to use HTTP/2 protocol? Do I have to add an extra parameter in the header?
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?
I use angularJS on the client side. My request go through Cloudflare to a server served by Play Framework.
回答1:
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.
So I would guess your “data” queries are on a different domain to your regular queries and that domain does not support 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.
来源:https://stackoverflow.com/questions/50210947/using-http-2-with-angularjs