Mobile app version of vmapp.org
Login or Join
Welton855

: Why insert static files (CSS, images, JavaScript, ECC) in a subdomain? Why so many big and little sites inserts static files (CSS, images, JavaScript, ECC) in a subdomain like media.example.com

@Welton855

Posted in: #Css #Images #Javascript #Static #Subdomain

Why so many big and little sites inserts static files (CSS, images, JavaScript, ECC) in a subdomain like media.example.com or s2.static.example.com?

What are the advantages? Why not just a directory like example.com/media/?

10.05% popularity Vote Up Vote Down


Login to follow query

More posts by @Welton855

3 Comments

Sorted by latest first Latest Oldest Best

 

@Steve110

Just because your http request will be smaller and the server will run fast and the requested file will be given in a very small time which will ultimately lead to the fastest page load

10% popularity Vote Up Vote Down


 

@Shanna517

I see at least three possible (good) reasons:


Use another machine to serve the static content

Including some CDN

Use another web-server to serve the static content

Something more lightweight and faster
No need for a full PHP/.NET/JAVA server to serve static content!

Using another domain name means that you'll be able to not have the cookies that are used on the main domain

Which means that HTTP requests will be smaller
Which can count, if you have a lot of traffic (see this post, for example : Performance Research, Part 3: When the Cookie Crumbles)



That's what is done on StackOverflow if I remember correctly

10% popularity Vote Up Vote Down


 

@Hamaas447

... use cookie-free domains for
components.

When the browser makes a request for a static image and sends cookies
together with the request, the server
doesn’t have any use for those
cookies. So they only create network
traffic for no good reason. You should
make sure static components are
requested with cookie-free requests.
Create a subdomain and host all your
static components there.


This advise was taken from Yahoo's Best Practices for Speeding Up Your Web Site.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme