Y
Y
Yuri2022-01-24 15:41:46
Web development
Yuri, 2022-01-24 15:41:46

Does it make sense to load site assets (css/js/img/fonts) from subdomains?

I know in browsers there is a limit of 6 simultaneous requests per domain.
it used to be popular to load assets from subdomains to get around the limitation and download more files at the same time.
what about HTTP/2? it seems to create a persistent connection and quickly load assets through it.
with each subdomain, logically, it is necessary to establish a separate connection?
at the moment, the site uses more than 10 subdomains for assets on one page.
Is there any point in subdomains or are they slower? or does it make sense to make a minimum of 1-2 subdomains?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Y
Yuri, 2022-01-24
@riky

Found the answer.
Dear Rubix gave a link to SO,
I will give a translation:


Browsers set a limit of 6-8 connections per domain when using HTTP/1.1, depending on the browser implementation. This allows a maximum of 6-8 concurrent requests per domain.
When using HTTP/2, browsers only open one connection per domain. However, thanks to the multiplexing function of the HTTP/2 protocol, the number of simultaneous requests per domain is not limited to 6-8, but is practically unlimited.
It is virtually unlimited in the sense that browsers and servers can limit the number of concurrent requests through an HTTP/2 configuration setting called SETTINGS_MAX_CONCURRENT_STREAMS.
Typical limits are around 100 (Firefox's default value for network.http.spdy.default-concurrent - note the spdy name here: it was the protocol ancestor of the HTTP/2 protocol), but could be higher (or, more rarely, lower) depending on the browser implementation and on the server you are running on. connect to.
Expect these limits to change over the years as HTTP/2 evolves and gets more widely used (just like it did with HTTP/1.1: browsers started with 2 connections and ended up with 6-8 after years of use, experience and setting).

so if the http2 server has almost no limits. And I think it's better to stop using subdomains, especially when there are a lot of them, because. with each you also need to establish a connection.
Alexander Falaleev rightly noted about cookies, on a regular site with different marketing terkers it can be + 2-3kb (in uncompressed form) or more for each request, so it might make sense to have a separate domain or CDN for assets.

L
Leonid, 2022-01-24
@caballero

No

A
Alexander Falaleev, 2022-01-24
@suffix_ixbt

It makes sense if the main site is located on www.site.ru - then the statics that you specified will be distributed from subdomains without cookies (respectively, a little faster). If the main site is site.ru, then cookies will be from all subdomains - then there is no smsysla to distribute the statics you specified from subdomains.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question