DEV Community

Petros Demetrakopoulos
Petros Demetrakopoulos

Posted on

What is the difference between and

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

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 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 support "CNAME" records that allow associating a subdomain with another domains or subdomain (such as 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!

Top comments (1)

gtb3nw profile image

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!