What is the purpose of the WWW subdomain?

Before the World Wide Web, there was still an Internet, and it was used for a variety of things: telnet, email, gopher, FTP, etc. At that time, it was traditional to assign domain name aliases to servers for common functions. So, smtp.example.com would be example.com's outbound email SMTP server, ftp.example.com would be example.com's FTP server, etc.

When the Web came along (early 1990's), it was just yet another application / protocol -- it wasn't necessarily envisioned at that time that it would be come the most popular thing to use the Internet for, next to email. So an organization's web server was assigned a domain name alias of "www." like any other service would have typically been assigned.

Over time many sites started dropping the "www.", because URLs are after all often typed in by people and yes it's 4 more characters than really necessary. But, "www." still lingers today and it's not likely to ever completely go away.


It is mostly used to separate cookies from the other subdomains.

If you are going to use cookies, definitely keep the www..

You can always use an 301 redirect to redirect the short domain to the one with www., that way your users don't have to type it.

This will allow you to create sub-domains that are cookie-less for static data serving. Without a www., cookies are served on all sub-domains. Therefore, if you are not using the www., you need a completely separate domain name to have a cookie-less domain versus just using a sub-domain.

Other than that, choosing between keeping the www. or not is just a question on which one you prefer. Just make sure to redirect the one not chosen to the other one using a 301 redirect.

EDIT:

To explain, setting a cookie uses a hierarchy for how the cookie is propagated to domain.

For example, setting a cookie to example.com effectively allows the transfer of cookies to:

example.com
www.example.com
sub.www.example.com
my.example.com
oh.my.example.com
images.example.com
hello.example.com

Versus setting a cookie to www.example.com only allows the cookie in those situations:

www.example.com
sub.www.example.com

By using a www. you are allowing yourself to use sub-domains to have different cookies from the main site (and none at all if so desired).

Without www. (or another sub-domain), all cookies set on the domain will propagate to the sub-domains.


No idea if this is traditionally why www. is used, but one possible reason:

Say you have a server which runs web, SMTP and IMAP servers. Users access the web server via www.example.com, SMTP via smtp.example.com and IMAP via imap.example.com

Your server becomes heavily loaded, so you want to split the web-server to a new machine. To do this, you simply change the "www" subdomain to point to your new web-server's IP address.

For larger internal networks, this is an easy way to move servers around.. Just change the internal SMTP server DNS entry and all clients will automatically start using the new machine. No forwarding of ports to worry about

With internet facing servers, you would probably keep both servers on the same NAT'd network, and forward port 80 to a different machine, or use a load-balancer

There are benefits to retaining the "www." part of the URL for purely web-servers, particularly with regards to cookies, as Andrew Moore and this blog.SO post explain.. Plus if you redirect the non-www domain, users don't have to type it (and even if you don't, most browsers will try "www.example.com" if "example.com" doesn't work)