Reputation: 282
index.html is loaded from server https://foo.com, which supports http 1.1 only, but with proper CORS header, an XMLHttpRequest can be sent out to a 2nd server https://bar.com, which supports http/2.
Will my application be able to leverage the http/2 features between the browser and server https://bar.com?
Upvotes: 0
Views: 3209
Reputation: 46040
Yes, it's a completely separate connection but I doubt it will matter as not sure what "features" you hope to benefit from?
Nearly all of the features and advantages of HTTP/2 are designed to improve performance of many connections to the same domain:
So unless your website is making huge numbers of XMLHttpRequests to the same host those features won't really benefit you that much. The overheads of HTTP/2 coupled with the implementations being fairly new and so probably not 100% optimal yet, will often mean that HTTP/2 could actually be slower for small numbers of requests.
That only leaves Server Push. This can only be sent in response to an original request, so is less beneficial for XMLHttpRequests in most cases. Additionally there seems to be some confusion as to how to handle pushed XMLHttpRequests.
Upvotes: 2
Reputation: 18617
Yes, your application will be able to leverage the HTTP/2 features provided by bar.com
.
This is also why CDNs providers are so interested in HTTP/2.
XMLHttpRequest
is no different: the browser still makes a HTTP request (whether it's to a CDN or via XMLHttpRequest
), and if bar.com
supports HTTP/2, the browser will make the call using HTTP/2.
Upvotes: 0