Images located in Subdomain

Avatar
  • Answered
I have read that it can improve website speed to have any images or videos located on a subdomain. Is there a link to a tutorial on how to set this up and how it works, etc.? I understand how to setup a subdomain, im a little confused as to whether I have to create an index page or just have folders located there for photos and videos. What happens if someone visits the media subdomain?
Avatar
JacobIMH
Hello, and thanks for the great question. You're correct that loading images from a subdomain can improve performance in some cases. The reason for this is that most web-browsers will only use two open sockets per hostname to download files. By using a subdomain such as images.example.com to load your image content, you can essentially add another two open sockets in parallel to download the images at the same time as your HTML content. You main website files would reside in /home/userna5/public_html/, and your images subdomain could be pointed to /home/userna5/public_html/images/. All you would simply need to do to utilize the images on the subdomain, is make sure that your links use the subdomain in the link itself. If someone just went to images.example.com you could either simply place a index.htm file in there to show what you'd like. Or you could place a .htaccess file inside the subdomain's directory and use this rule to disable directory listing:
Options -Indexes
Now please note that simply hosting images from a subdomain won't cause a huge increase in speed, but it can definitely help in certain cases. Also if you have an SSL certificate securing your main site, and are including images from a subdomain, this will cause security warnings in your browser if you don't have a wildcard SSL. Please let us know if you have any further questions at all. - Jacob