2

A few days ago, I conducted a major experiment on my site. Before then, I had major sections of the site categorized as domains. For example:

http://pictures.example.com/whatever
http://help.example.com/whatever
http://internalstuff.example.com/whatever
http://tips.example.com/whatever

Now I converted most of the domains into one so that accessing the same resources is as follows:

http://example.com/pictures/whatever
http://example.com/help/whatever
http://example.com/tips/whatever
http://internalstuff.example.com/whatever

I left one subdomain alone because its strictly meant to be used for assets but I'm wondering if that is even a good idea anymore because I have my site currently setup to load pictures after the HTML loads, not while the HTML loads.

After converting 6 subdomains into one domain using the method above, and running mobile tests with webpagetest.org, it turns out the time to first byte significantly decreased from 210ms to about 135ms.

So my question is, with such a large image site like mine, Am I better off to just run everything off of only one domain and hope for the lowest time to first byte, or should I keep my assets running off of a subdomain?

I'm just trying to figure out if there is really any kind of advantage to using a subdomain.

And as a side note, since the merge, my income at least doubled on average.

6
  • 1
    Only if your first byte sucks... Sub domains, or multiple domains benefit from parallel downloads because most browsers will only request up-to a max of 6 per a domain. If you want better parallel downloads get a CDN as its much faster and the first-byte will also be much lower due to CDN's using the nearest mirror. Feb 15, 2016 at 17:56
  • GTmetrix recommend using 2-4 hostnames to help parallelize downloads, but with HTTP/2, the maximum number of browser connections per host is less of an issue. What server are you using, and are you willing to switch to HTTP/2 or do you prefer an answer for legacy HTTP/1.1 connections? Also, have you already done basic optimizations like combining requests (e.g. combine multiple CSS stylesheets into one)? This is easier and gives a bigger speed boost. Feb 15, 2016 at 18:02
  • I should add that for 99% of the pages a maximum of 4 items are downloaded: The image, two sets of image sprites and the HTML. The only thing different between changing image pages is the image itself and the HTML. The sprites are cached. Feb 15, 2016 at 18:09
  • Oh, and I'm using apache and can only deliver HTTP/1.1. and yes I've done as many optimizations as possible from server level to website level including code optimization. Feb 15, 2016 at 18:10
  • Nice work reducing page loads to four items. I see way too many websites ignoring this step and using dozens of tiny individual CSS & JS files that should have been combined into one. Third-party Wordpress themes seem to be the worst offenders. Feb 15, 2016 at 18:25

2 Answers 2

2
  1. Don't confuse with HTTP/2, because webmaster still need to use cookie less subdomain or external domain to serve asset files.

  2. Don't use subdomain to serve static assest, if you're using naked domain like stackoverflow.com, because if you use third party service like Google analytics, then your cookies will pass to all other subdomain. So use subdomain only, if you're using www or similar subdomain to serve webpages.

1

Based on your comment "I should add that for 99% of the pages a maximum of 4 items are downloaded" the answer for your use-case is definitely no. Four page assets are well within the maximum number of connections a modern browser will make, and spreading those four page assets across multiple domains is pointless.

For others reading your question title and wanting a more general response, the answer is definitely yes. That's because most websites have more page assets to load and spreading them out across domains helps. Here is an implementation guide from GTmetrix which is a great place to start learning more about it.

Note that newer versions of web servers are starting to support HTTP/2 which alleviates this restriction and permits many more concurrent downloads at once. That's probably the best choice going forward but it requires more work to set up.

1
  • In that case I'll just consider my merge a good move and then go with two subdomains. One for assets, and one for HTML. Feb 15, 2016 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.