: 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
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/?
More posts by @Welton855
3 Comments
Sorted by latest first Latest Oldest Best
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
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
... 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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.