Use Http/2 to make api calls from javascript

拟墨画扇 提交于 2019-12-04 13:48:59

When the browser and server both support HTTP/2 then it will be used for all calls from the browser - including XHR. You don't need to do anything special in your javascript to enable this. That's one of the great things about the way HTTP/2 was implemented.

If you are asking how to ensure the connection is held open for as you want to reuse the connection then the http/2 spec says:

HTTP/2 connections are persistent. For best performance, it is expected that clients will not close connections until it is determined that no further communication with a server is necessary (for example, when a user navigates away from a particular web page) or until the server closes the connection.

...

Servers are encouraged to maintain open connections for as long as possible but are permitted to terminate idle connections if necessary.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!