3 ms·
well, using www for one lets you avoid buying a completely different domain to serve static content in a cookie-less fashion.
by foo123456 10y ago
well, using www for one lets you avoid buying a completely different domain to serve static content in a cookie-less fashion.
- Abundnce10 10y agoI don't understand what you mean. Would you mind expanding on this?
- jordanlev 10y agoEvery time you request something (a web page, an image, a css file, etc) from a server, your browser sends any cookie data that had previously been set by that server as part of the request header. Cookies can be set for specific subdomains only, but if they are set for the "unprefixed" domain they will also be sent for all subdomains (just the nature of how browsers handle cookies). Since cookie data is rarely needed just to server static assets (images, css files, etc), you can shave off some time on each request if you serve them from a subdomain that is different from the web page's subdomain... but of course your web page has to actually be at a subdomain (e.g. www.example.com) in order for this to work. Hence, setting up your main web pages to be at a subdomain (such as www.) gives you the ability to then serve static assets from different subdomains without browsers having to send cookie data on each request.
- mxuribe 10y agoNice explanation on this!
- zrail 10y agoCookies are scoped to a domain name and all subdomains under that domain name. For example, if you set a cookie on `ycombinator.com` that cookie will be presented to `news.ycombinator.com` as well. Using `www.example.com` as your cookied domain allows you to avoid sending your cookies to `cdn.example.com`, shaving off a few bytes of incoming bandwidth per request. Whereas if you use `example.com` as your cookied domain, those cookies will be passed to `cdn.example.com`. To avoid that, you'd have to set up your CDN on a completely different domain like `examplecdn.com`.
- mxuribe 10y agoAnother nice explanation on this!