1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Does it help to use subdomains for image and javascript hosting?

Discussion in 'Server Configuration and Hosting' started by Lone Wolf, Jun 2, 2015.

  1. Lone Wolf

    Lone Wolf Well-Known Member

    My forum got a 0 score for subdomain usage on a speed test website so I was reading a few guides to see what it was all about.

    Does it help speed up the website if you load different types of contents from different subdomains? For example...

    images.mydomain.com (for attachments and server hosted images)
    scripts.mydomain.com (for javascript, etc)

    Does this work and what other subdomains would be useful because the advice was for 4 to 5 subdomains?

    Would be great to hear from anyone who has experience with this.
     
  2. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    Different sub-domains are considered as "different sites" and since there is a limit to number of connection per host by the browser using different sub domains will increase the number of active connections, thus loading the site faster :)
     
    Lone Wolf likes this.
  3. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    And as for suggestions, you can have a different sub-domain for the data directory. ;)
     
    Lone Wolf likes this.
  4. Lone Wolf

    Lone Wolf Well-Known Member

    Does this involve moving directories around or can I leave the setup as it is and just call the directory via the subdomain?
     
  5. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    Not needed, you can just point the sub-domain's document root to /home/username/public_html/data, update the config.php file to the 'data' URI to the new sub-domain and you are good to go! :D
    PHP:
    $config['externalDataUrl'] = 'http://data.domain.com';
     
    Ryan Nielson and Lone Wolf like this.
  6. thedude

    thedude Well-Known Member

    With SPDY and the recently finalized HTTP2 standard, no, multiple domains won't improve speed, if they're all pointing to the same physical server.

    All major web servers (apache, litespeed, nginx, etc) will have support for HTTP2 in the very near future so it may not be worth your while to shard your domains (make multiple asset domains) at this point.
     
    Gossipy, Ryan Nielson and Lone Wolf like this.
  7. Lone Wolf

    Lone Wolf Well-Known Member

    We wont be updating to HTTP2 + SPDY for a few weeks yet. UNtil we do that, wouldnt the subdomains thing help out
     
  8. thedude

    thedude Well-Known Member

    If the only purpose is to score better on that site analysis test, I wouldn't bother. Since you're switching in the near future to the newer protocols, it'll very much be a waste of time.

    On the other hand, if you want to offload your static assets (images, javascript, etc) to a content distribution network such as CloudFlare, Amazon CloudFront, or MaxCDN, then I would recommend creating a new domain, or using a subdomain of your existing domain for that. You'll only need one domain (or subdomain) for it, since CloudFlare currently uses SPDY, and all the major CDN's will use HTTP2 in the near future. So instead of images.mydomain.com AND js.mydomain.com, you could just create static.mydomain.com. However the better alternative would be to create an entirely new domain just for the assets so it's cookieless.

    Here's a good guide for using XF with a CDN. The key parts are under the heading "How To Add Your CDN in Xenforo Settings"

    We use CloudFlare with a completely separate domain than our website, and they're able to cache on average > 87% of our static data requests (javascript, etc), so our server can use its resources for generating the php pages for the visitors.
     
    Last edited: Jun 2, 2015
    Ryan Nielson and Lone Wolf like this.
  9. Lone Wolf

    Lone Wolf Well-Known Member

    That looks really good but my site isn't all that busy, I just want to speed it up and optimise it as much as possible without spending any more as my budget is stretched with the VPS already.

    How much would a CDN charge per month for a setup like that?
     
  10. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    You can use CloudFlare's free plan ;)
     
    thedude likes this.
  11. thedude

    thedude Well-Known Member

    What @Mr. Goodie2Shoes said. Their free plan is great...
     
  12. Lone Wolf

    Lone Wolf Well-Known Member

    There must be limits, what sort of traffic is the free plan limited to?

    I was recommended MaxCDN.
     
  13. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    Not that much... check it out: https://www.cloudflare.com/plans
     
  14. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    And not that much as in the free plan has everything you currently need ;)
     
  15. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    MaxCDN is a full-blown CDN provider that you will need when you have quite a lot of traffic. Till then CF is you number one choice. :D
     
  16. Lone Wolf

    Lone Wolf Well-Known Member


    According to that there are no mobile optimisations as part of the free package. I want to speed up the mobile site more than the desktop, wouldnt it be better to do it as a subdomian in that case?
     
  17. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    Not really... I think the optimizations include compressed images and such which wont help even with sub-domains.
     
  18. Lone Wolf

    Lone Wolf Well-Known Member

    @Mr. Goodie2Shoes @thedude

    Thanks for your help guys. I'm planning to talk to my server guys and go ahead with using CloudFare to CDN my subdomains. Is this ok...

    images.mydomain.com
    js.mydomain.com
    styles.mydomain.com
    data.mydomain.com

    I'm just tying to get a few concurrent downloads per page to ensure a quicker load speed.
     
  19. The Dark Wizard

    The Dark Wizard Well-Known Member

    I'm using them to great success on https://www.rpnation.com

    I have i for images, d for data and j for javascript.
     
  20. thedude

    thedude Well-Known Member

    The header pic on your site is almost 1MB. You definitely want to shrink that file size down...
     
    Last edited: Jun 4, 2015

Share This Page