loading...

What is the difference between mywebsite.com and www.mywebsite.com?

demetrakopetros profile image Petros Demetrakopoulos ・1 min read

So the other day a friend asked me "What is the difference between the domains mywebsite.com and www.mywebsite.com"?

The differences are mainly technical but important.

The 2 basic differences in very simple terms are relevant to cookies and the ability to change the "destination" that a domain "maps" to in the DNS level.

So regarding cookies...

The core difference for cookies is that a "naked" domain (like mywebsite.com) send the cookies belonging to them to the subdomains they have if the site in the naked domain uses resources from them (or simply requests data from them). As you may understand, this may cause a waste of bandwidth because most of the subdomains (if not all) have no reason to be aware of the cookies of the main site. In contrast, subdomains do not send cookies to other subdomains (unless explicitly stated in the Set-Cookie header of an HTTP response header)

Regarding DNS and CNAME records

Naked domains can only be associated with "A" DNS records. A records only allow the domain to be associated with a specific IP Address. However, subdomains (like www.mywebsite.com) support "CNAME" records that allow associating a subdomain with another domains or subdomain (such as server2.mywebsite.com). This is very helpful in situations where you may need to manage and move traffic from one server to another (you can do it by simply changing the domains/subdomains that a subdomains "maps" to in the CNAME record).

I hope you find it enlightening and helpful!

If you have any comments Let me know!

Posted on Apr 15 by:

demetrakopetros profile

Petros Demetrakopoulos

@demetrakopetros

Code-blooded, Computer Science graduate from Athens University of Economics and Business. I am a professional Full-Stack web developer with main expertise in iOS, Node.JS, Express.JS and Loopback.

Discussion

markdown guide
 

Regarding CNAME's, most major DNS providers provide an ALIAS/ANAME record type which is synthetic and fixes the apex record issue.

As for the cookie problem, if you're specific and scope the cookie to the apex domain it will only work for the apex domain. If you don't scope it, you leave it up to the browser to determine and that varies. I'd argue that's a browser issue and you should be scoped to a domain as default.

Let www die already! Redirect to non-www!