22 ms·
Should you use www or not in your domain? (2017)
- austincheney 8y agoThe article suggests using WWW for DNS compatibility, but... Everything it mentions in prefer for WWW can be solved by a combination of static IP and CDN. My site's domain, for example, has a domain with a static IP and the site is served by HTTPS. Certificate resolution for the HTTPS goes to CloudFlare which also serves as a CDN for everything retrieved from the domain. CloudFlare provides firewall and security options as a feature of its CDN capabilities. Because I am already solving for all the DNS and application concerns mentioned by the article I choose to use the more sane approach and simply drop use of a default subdomain. EDIT: I also detest cookies. They can store virtually nothing at 4kb per domain and the cookie API is horrible. Instead I use localStorage for all storage concerns and share explicitly anything that needs to be shared via XHR, which currently is nothing.
- asaph 8y ago> ... and the cookie API is horrible. What don't you like about it?
- austincheney 8y agoIt is arguably worse than the Date api. https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie https://developer.mozilla.org/en-US/docs/Web/API/Document/co... Compare all that madness to the localStorage API: localStorage.myName = "string up to 5mb"; Attempting to delete a cookie makes me want to abandon coding. Removing from localStorage is as easy as: delete localStorage.myName;
- asaph 8y agoThe client-side API for cookies is irrelevant since it's disabled when the httponly flag is set on a cookie. And all cookies should have httponly set to true for security reasons. You should only be using server-side APIs for cookie management. Many good ones exist. Reference: https://www.owasp.org/index.php/HttpOnly https://www.owasp.org/index.php/HttpOnly
- austincheney 8y ago> You should only be using server-side APIs for coookie management. No. I will use any string I want of any size I want. Cookies are a relic of an archaic age for the web. Cookies only continue to be used because many server based web applications haven't figured out a modern way for managing sessions.
- asaph 8y agoStoring arbitrary data in a cookie isn't a secure best-practice anyway. You shouldn't store actual data in cookies, just a meaningless token (aka session-id) that is used to look up session data on the server side. If you insist on using local storage, please be aware that it's unsuitable for storage of any sensitive data for the same security reasons that the httponly cookie flag exists. Don't let your API elegance preferences be the only factor in your architecture design choices. Please consider security too as you may be putting your users at risk. Design choices in this area are more nuanced than you seem to be aware of.
- hacknat 8y agoNot everyone can get a static IP for their site and if everyone did we would be out of IPs.
- rebane2001 8y agoIt's done using a CDN. Eg CloudFlare has an IP your website is on, but also where many other websites on the same IP
- Avamander 8y agoEveryone can get a static IPv6 IP.
- system2 8y agoGood luck typing it.
- austincheney 8y agoWe are out of IPs regardless, at least IPv4 addresses. We are nowhere close to running low on IPv6 addresses.
- dbrgn 8y agoCookies and local storage are two different things. Use local storage if you want to store data on the client. Use cookies if you want to share data with the server. And regarding Cloudflare: Terminating your TLS session on a third party provider's server also has it's downsides.
- update 8y ago> Conclusion: Go with www Am I missing something or is OP using a non-www domain? I'm using Chrome fyi (mentioned because I know safari messes with the address bar)
- shapiro92 8y agoyep he defaults without www.
- nasredin 8y agoHis non-WWW site is broken. If you manually append the WWW, the site works. Guess he is Stallmam-serious about practicing what he preaches. Also this is a stupid clickbait non-issue.
- okanesen 8y agoYeah, in the comment section he does state[1], that you should stick with the one you have decided to pick in the first place. [1]: https://bjornjohansen.no/www-or-not#comment-510 https://bjornjohansen.no/www-or-not#comment-510
- consto 8y agoIf you are not using or planning to use sub-domains, the only issue is that you cannot use CNAMEs. This is nearly a non-issue as many DNS providers offer ALIAS/ANAME/ACNAME records that essentially provide CNAMEs on apex-domains.
- admax88q 8y agoChrome messes with the address bar as well.
- amingilani 8y agoOP here, minor nitpick: I'm not the author, I just found something interest and posted it. That said, I agree. The author does jump to conclusions, but that's pretty much why I posted it. It's was first search result and I decided an HN debate would help me find a better answer.
- RKearney 8y ago
- JeremyBanks 8y agoSite is down. Mirror: https://web.archive.org/web/20181111141630/https://bjornjohansen.no/www-or-not https://web.archive.org/web/20181111141630/https://bjornjoha...
- paulsutter 8y agoHe gives two reasons to default to www: - Cookies are passed down to subdomains / unnecessary cookies hurt performance / cookies may be read by third parties - DNS origin can’t be a CNAME (must be an A-type record, that points to a static IP address) He is using the non-www like everyone else, of course. We always list out the practical reasons that www is better, just before we choose non-www.
- shawn 8y agoWhen your site grows large and you move it to an hosted service, or wants to point it to an Web Application Firewall or a DDoS mitigator, you might want to use a CNAME type record, to point the hostname to another flexible hostname that the vendor manages depending on your traffic and needs. Now, if your website is hosted at the origin (“example.com”), you can’t do that. But there is no issue with the “www” hostname being a CNAME record. So if you want any scaling flexibility, now or in the future, you should go with the www hostname from the beginning. Granted, his blog was knocked offline by HN. But would a CNAME have saved their Wordpress site? FWIW, https://ycombinator.com/ https://ycombinator.com/ redirects to https://www.ycommbiator.com https://www.ycommbiator.com, as does Reddit.
- deleted 8y ago[deleted]
- terandle 8y agoI can appreciate the pragmatic aspect of choosing www however I don't really like the 'oh well guess we'll just use www forever' attitude either. Seems like changing the specs to remove these restrictions is what we should really be talking about?
- marcus_holmes 8y agoI'm grappling with this question at the moment. The problem is that Let's Encrypt doesn't support wildcard certs, so having a single cert for the origin and allowing connections on "www." is not possible. This is a problem because a request on "https://www." https://www." will be rejected completely rather than redirected to the origin (or vice versa). In other words, I have to choose one, and the other one won't work at all and can't be redirected (for https, but I'm auto-redirecting from http to https as well, so for everything). Obviously, the marketing gains from not having a "www" outweigh any other considerations at this point, so no "www". As I understand it, anyway. I could be wrong. I hope I'm wrong, and have just misunderstood how this all hangs together.
- jasonjayr 8y agohttps://community.letsencrypt.org/t/acme-v2-production-environment-wildcards/55578 https://community.letsencrypt.org/t/acme-v2-production-envir... They do support wildcard certs now.
- zie 8y agoThey do, and it's fabulous, but *.example.com certs from LE do not cover the root domain (example.com) so if you do a wildcard cert, you then must also do www.example.com. unless I'm missing something :)
- pseudalopex 8y agoYou can have example.com and *.example.com on the same certificate.
- jasonjayr 8y agoI didn't find docs specific to wildcard + non-wildcard, but LE certs can use multiple subject alternate names. So whatever tool you use, use SAN to request both *.example.com and example.com into one cert. I imagine you have to setup your stuff to respond to the DNS + web based challenge/response.
- NotANaN 8y ago
- nobody271 8y agoShould you use your turn signal in the turn lane when it's already implied? If yes, what about a two lane when you are in the outside lane? Did you know when you turn you are supposed to go into the closest lane and then change lanes again as opposed to driving through the close lane? My point is web developers will do whatever they want. Technically you should use www for your website. But if your domain is known for being a website the www is implied and you could make an argument for leaving it out. But no one cares. This isn't linux where you can force users to follow obscure rules to get your software to work. You simply just won't get that traffic. And that, is justice! So we all know the answer already. Redirect https:// https:// to https://www https://www or vice versa depending upon on your inclination.
- bjterry 8y agoYou should always use your turn signal even when it's already implied, because that implication is not obvious from every vantage point near an intersection to people who are potentially crossing your path (and who may already be moving towards your path at speed).
- tejohnso 8y agoAlso, it's nice to know that the person is in fact meaning to turn, rather than just being in the wrong lane. When dozens of 3,000 lb death boxes are travelling at high speeds in close proximity to each other, and in close proximity to slow moving, talking creatures made out of meat, it's best to communicate as clearly and possible.
- bhandziuk 8y agoWhat about an on ramp? There's no signal and no intersection. Just a road diverging from another.
- wolco 8y agoBut you signal when you merge.
- crazygringo 8y agoThe reasons given for using www are honestly very weak, just edge cases really. As far as cookies are concerned, keeping them on the origin ensures they get passed to all subdomains, which is usually a benefit, as opposed to a problem -- which you'll discover when you need to restrict API requests on a subdomain only to logged-in users, for example. And as long as you're keeping your cookie payload small, like a session ID or two, there's zero worry about a performance hit. And as far as a CNAME needing to point to another domain instead of an IP, has that ever been an issue for anyone? Genuinely curious. I'd never even heard of that until now. Honestly, simpler is better and "www." is an unnecessary vestige from another era. I dropped it from my sites starting a couple years ago. (Obviously with a redirect in case anyone ever types it.)
- ericpauley 8y agoCNAME is absolutely an issue, especially when using managed hosting. Many hosts require that you CNAME since they move around IPs. (e.g. Heroku) so unless you put a provider in front of them that integrates with your DNS you need www.
- hacknat 8y agoYou can add AWS, Azure, and GCP to this list. Most people don’t want to lay out the money for a static IP, and why should they?
- yegle 8y agoNot true for App Engine: we have a fixed set of IP addresses to be used in A/AAAA record. Disclaimer I work on App Engine.
- hacknat 8y agoThis FAQ on App Engine specifically says you guys can’t map a static IP to a site: https://cloud.google.com/appengine/kb/ https://cloud.google.com/appengine/kb/
- no_gravity 8y agoLet's take a look what the top sites according to Alexa do: https://www.alexa.com/topsites https://www.alexa.com/topsites Google: www Youtube: www Facebook: www Baidu: www Wikipedia: www I see a trend here... Would be interesting to go through the whole list and get a broader statistic. Let's look at some of the newer/hipper sites on the list: Reddit: www Instagram: www Netflix: www Twitch: www Spotify: www So all 10 out of 10 major sites I visited redirected me from the non-www to the www version.
- glenneroo 8y agoI wonder how much that has to do with Chrome and Firefox (and probably other browsers?) prepending www (and https). edit: I guess both of mine have some plugin doing this?
- rolodato 8y agoIn the case of Google, not at all: $ curl -v https://google.com [...] < HTTP/2 301 < location: https://www.google.com/
- amenod 8y agoJust an FYI: in this case you might want to use `curl -i` which will display just headers + body (switch `-v` displays lots of other information too). $ curl -i https://google.com HTTP/1.1 301 Moved Permanently Location: https://www.google.com/ ... EDIT: interesting that it responds with HTTP/2 in your case and HTTP/1.1 in mine, would need to look up why the responses are different.
- hacknat 8y agoNot at all. A browser would never do this. It would break a lot of sites!
- deleted 8y ago[deleted]
- dexterdog 8y agoThe bigger question for him is: should you use a CDN to handle your HN DDoSes?
- system2 8y agoThe writer is a typical "do what I say, don't do what I do".
- jpswade 8y agoI wrote about this over 10 years ago and it mostly still holds true today... See: https://wade.be/yes-www/ https://wade.be/yes-www/ I still think the best argument for keeping www is from Heroku: "Root domains are aesthetically pleasing, but the nature of DNS prevents them from being a robust solution for web apps. Root domains don't allow CNAMEs, which requires hardcoding IP addresses, which in turn prevents flexibility on updates to IPs which may need to change over time to handle new load or divert denial-of-service attacks."" See: https://web.archive.org/web/20110628072339/http://status.heroku.com:80/incident/156 https://web.archive.org/web/20110628072339/http://status.her... Like most things in technology, if Amazon, Facebook and Google are all doing it, it's probably for good reason...
- sneak 8y agoThese days almost all dns providers support dns-server-resolved CNAMEs (ANAMEs as they are known). I don’t think this is really much of an issue anymore.
- ericpauley 8y agoAWS Route 53 doesn't support this for external CNAMEs, just aliases for amazon resources.
- paulddraper 8y agoBut not Twitter?
- tln 8y agoI don't think Amazon Facebook and Google would have any technical trouble using an alias... "www" is all about conforming to expectations
- RKearney 8y ago> which requires hardcoding IP addresses That statement couldn't be more wrong. It's absolutely possible to programmatically update DNS records. Set the TTL low (which you would be anyway for the CNAME records) and change them as you see fit.
- 8y ago
- b1r6 8y agoFor my own domains, I have a large number of subdomains and a less-important root page. Because of that, I redirect www -> non-www. It makes me think "this is the root."
- amingilani 8y agoThe biggest reason to not use the apex domain is because a CNAME on the apex will render other records unreadable, and ANAMEs suck. They're great reasons. However, Cloudflare already offers something called CNAME flattening for apex domains and there's already an AAAA record type that works like a CNAME but without all the problems they cause. Granted, not all DNS providers support this, but if they do, is there else anything wrong with using the apex domain? Isn't the cookie problem a solved problem?
- systematical 8y agoThis is such an unimportant question. We use www at work and redirect non-www to www. We could just as easily change that if we needed to. But it doesn't really matter either way.
- gaius 8y agoYes of course www. We should resist all attempts to deprecate URLs so the entire web will be hidden behind Google's search box. SEO is a plague.
- saagarjha 8y agohttp://example.com http://example.com is a valid URL.
- quintin 8y agohttps://serverfault.com/questions/145777/what-s-the-point-in-having-www-in-a-url https://serverfault.com/questions/145777/what-s-the-point-in... " One of the reasons why you need www or some other subdomain has to do with a quirk of DNS and the CNAME record. Suppose for the purposes of this example that you are running a big site and contract out hosting to a CDN (Content Distribution Network) such as Akamai. What you typically do is set up the DNS record for your site as a CNAME to some akamai.com address. This gives the CDN the opportunity to supply an IP address that is close to the browser (in geographic or network terms). If you used an A record on your site, then you would not be able to offer this flexibility. The quirk of the DNS is that if you have a CNAME record for a host name, you cannot have any other records for that same host. However, your top level domain example.com usually must have an NS and SOA record. Therefore, you cannot also add a CNAME record for example.com. The use of www.example.com gives you the opportunity to use a CNAME for www that points to your CDN, while leaving the required NS and SOA records on example.com. The example.com record will usually also have an A record to point to a host that will redirect to www.example.com using an HTTP redirect."
- lotyrin 8y agoYep. Source: had to navigate the shitty position of trying to CNAME to a CDN and have that CDN's DNS infra replicate our e.g. MX records.
- cortesoft 8y agoA lot of DNS providers these days will give you a pseudo-cname on apex... basically having the dns resolver do a lookup of another dns name and return that as an A record for the apex.
- guitarbill 8y agoCloudFlare calls this CNAME flattening, right? [0][1] Personally, I always enjoy engineering solution that mean we're not stuck with old decisions forever. I chose the non-www as a teenager, and I'm glad 10+ years later I could add email to my domain no problem. [0] https://blog.cloudflare.com/introducing-cname-flattening-rfc-compliant-cnames-at-a-domains-root/ https://blog.cloudflare.com/introducing-cname-flattening-rfc... [1] similar discussion, 2014: https://news.ycombinator.com/item?id=7293512 https://news.ycombinator.com/item?id=7293512
- unilynx 8y agoThe no-CNAME-at-root issue is long overdue for a fix, but it looks like potential solutions are still in the discussion phases My vote is for just letting CNAMEs work at the root, apparently a lot of DNS software already lets you get away with it: https://mailarchive.ietf.org/arch/msg/dnsop/awmoLxtbQtQhSt9KDTr9JASy49k https://mailarchive.ietf.org/arch/msg/dnsop/awmoLxtbQtQhSt9K...
- vortico 8y agoA domain is a marketing tool as much as anything else on your web page. If customers see a "www." in the address bar, it slightly dilutes the visibility of your brand in the main domain. I believe this is more important than any technical issue listed.
- wolco 8y agoDoes it dilute or position your brand? www for most gives the initial impression of web/technical/site to the average person. Removing www dilutes the association to those concepts. Using the www in print removes the need to include http:// http:// otherwise domain.io might be confusing.
- jamieweb 8y agoUsing www probably helps for the newer gTLDs, as the average non-technical user may not realise that something like ".productions" or ".hockey" is a valid domain. In the past I've heard of non-technical users adding ".com" to the end of one of these gTLDs, which obviously takes them to a completely different website. I wonder whether anybody has used this as a form of pseudo-typosquatting or phishing?
- tgb 8y agoYes, I have this concern with the new deluge of TLDs. Now something.anything could be a link but also means it might not be. www.something.anything would at least make that clear if your TLD is not easily recognizable. Even recognizable brands give me double-takes when they use their TLD like a .google address doesn't look like an address at all.
- throwaway2016a 8y agoNo mention of iframes and cross domain Javascript for some reason. One potential attack vector if you allow user defined content on subdomains is that they can embed an iframe of your primary domain and they use Javascript to read the contents and execute code in it. Which they cannot do if the subdomains are different unless the page inside the frame explicitly sets "document.domain" Of course you can get a similar effect by using the "X-Frame-Options" header but if you are doing something like allowing user-defined content it is best to have layers and do different subdomains AND X-Frame-Options. Basically if you have an application that allows users to host Javascript, either use a completely different domain or make sure your root domain doesn't host any meaningful content or have cookies that are used for security or privacy.
- bhartzer 8y agoAs we move towards using more not-COMs and “dot whatevers”, right now it’s actually better to use a www since many non-technical people may not know that alphabet.xyz is a domain name. So in any offline marketing I’d definitely add www to the beginning of a not-com. For SEO purposes, if traffic is just clicking from one site to another, like from a search engine, the url doesn’t matter. But it does pay to be consistent, though. The main issue can be duplicate content isssues, so you should choose one version. Same goes for all 4 versions, though, if you add http vs https into the mix. Choose one. I can see www not being needed to tell the non-techies that a not-com is a domain name or web address as they get more used to not-coms. I senior taking another 5 years until we get there.
- patrickmcnamara 8y agoAlphabet actually uses 'abc.xyz' which looks even less like a domain name. Using 'www' would probably ruin that domains aesthetic though.
- thimabi 8y agoOn the other hand, Alphabet's target demographic is likely not to be misled by the lack of “www”. I'd be impressed if too many people outside of tech & finance actually knew what Alphabet is all about. In any case, their domain name certainly serves its purposes :)
- snowwrestler 8y agoI doubt that Alphabet cares if anyone goes to that website, though. I don't think it has been updated since the day it launched, has it? All their public services default to subdomains, including www. Although technically Google Search should probably load at search.google.com if it were going to be consistent with the URL convention of all their other services.
- amelius 8y agoI'm using wwww just to fool everyone.
- nothingburgers 8y agoOh brother, why is this a discussion? All opinions are trivially catered to with a simple HTTP 301 redirect, to send users in the direction of your choosing. Or not! You can also solve this with DNS! Whether an individual happens to request the WWW subdomain, or not, there are many ways to reduce confusion, and explain to their client-side user agent where they should be, or also support their expectations at zero cost. Just like HTTP versus HTTPS. It's a non argument. The HTTP/HTTPS problem is actually more difficult, has a handful of corner cases which are not solved, and yet the world still turns, and people are flexible enough to negotiate the perils of uncertain availability across protocols. You can support both. There's no reason not to. And even when there is, you can inform people of proper adjustments and corrections. Whoopty-doo!
- pwpwp 8y agoWhy isn't he using www for his site?
- omerh 8y agoWith www Optional wize: easy dns handling and wildcard ssl will serve any other future sub domain dns. Seo wise: google prefers it And if I’m not mistaken there and rfc for it. I can look later
- omerh 8y agoSorry for the typos. Operational wise There is an RFC for using www
- bmalehorn 8y agoThe article makes it sound like you have to choose between two options: 1. users see example.com in the address bar 2. hosting on www.example.com However you can get the best of both worlds. If you go to amazon.com, you will see amazon.com in the address bar. Yet your browser makes requests only to www.amazon.com; the content is hosted on www.amazon.com. Does anyone know how they pulled that off?
- alangpierce 8y agoI think this is just a Chrome UI thing (which a lot of people complained about): https://www.digitaltrends.com/computing/chrome-69-will-display-www-url-but-chrome-70-will-change-that/ https://www.digitaltrends.com/computing/chrome-69-will-displ... For me, the "www" shows up in Chrome 70 and Firefox. Chrome 72 hides the www again.
- theodorton 8y agoThis was changed in a recent version of Chrome, I believe. See this post on Super User: https://superuser.com/questions/1356867/chrome-69-hiding-www-and-protocol https://superuser.com/questions/1356867/chrome-69-hiding-www...
- deleted 8y ago[deleted]
- janaagaard 8y ago> Conclusion: Go with www But the site hosting the article does not use www...
- the_clarence 8y agoNo. Chrome, safari have removed these from the url bar, www has no meaning anymore.
- joshstrange 8y agoI wrote about using a CNAME on your root a fews years ago that covers the MX (email) records and problems it can cause. https://joshstrange.com/why-its-a-bad-idea-to-put-a-cname-record-on-your-root-domain/ https://joshstrange.com/why-its-a-bad-idea-to-put-a-cname-re...
- drudru11 8y agoSo it looks like chrome’s decision to hide the stable URL prefix is a good idea now. Interesting. The technical reasons really make me lean towards using www.
- qwerty456127 8y agowww is an atavism that doesn't make any sense today (as today the majority of web documents are generated dynamically, a URL is meant to identify a document rather than to locate it physically and public DNS and IP addresses rarely have 1-to-1 relation to a physical web server). Nevertheless many people still enter web addresses with www. Whenever somebody requests a URL with www it should just redirect to without www.
- alwaysreading 8y agoUm, the linked article does not contain www...
- gargalatas 8y agoIt's very very weird that you approach the problem from the userland (all of you) rather than from the administration angle. No it's not a marketing or a web designer problem. First of all it's an administration problem. WWW implies the protocol. FTP implies the protocol. MAIL implies to protocol and goes like this. You like it or not this is the main purpose of this usage because back in the day http was not the most famous protocol. Other protocols like FTP for example was very very famous and important too. But even today, when we see "www." in an FQDN we automatically understand that http:// http:// is implied. But also a very serious reason is the computer science reason. It'a a matter of tidyness and a right theoretical approach the usage of WWW. When a DNS issue will come up no one marketing guy or designer will be there to help you, you poor admininstator. So please leave this decision to the admins and the way they established it. With WWW!
- jodrellblank 8y agoIt's very very weird that you approach the problem from the userland (all of you) rather than from the administration angle. Is that really weird at all? "you take the pain so your customers have things more pleasant" is a common idea. None of your customers care if you are doing "the right theoretical approach to the usage of www" if your competitor isn't. They'll simply go to your competitor, who does the thing they want. e.g. "CNAMES at the root of DNS" which is mentioned in this post; you can find any number of greybeards lecturing you on how wrong it is, but when you face your customers and they say "Amazon Route 53 DNS lets us do it", what does it matter how wrong it is? Explaining to them how Amazon has built something custom and non-standard, won't make them happier. They'll just use Amazon.
- gargalatas 8y agoAre we talking about a small shity startup with a CEO that knows everything or a big serious company like google where scientists debate of what is right or wrong?
- avarun 8y agoThere are no "scientists" at Google debating whether things are right or wrong. As with all companies, it is the product and business leaders of the company that make this decision, and they make it based on what attracts the most users.
- arrty88 8y agoWhat do the URL shortner services go with?
- DFHippie 8y agoYou should use 'www' so you can say "sextuple-u".
- ToFab123 8y agoYes, because when trying to give en url to an elderly or a non-technical, I find that, they often gets confused if it doesn't start with www.
- stock_toaster 8y agoIf only http used srv records instead.
- LinuxBender 8y agoThat would be great, but it does not appear to be included in http 3.0. At least, google does not agree it is needed, so it won't likely be. It can only be added in a major protocol version.
- wnevets 8y agoSeems like everyone is focusing on reasons why you should use www and why those reasons aren't important. Any reasons why you shouldn't use www besides 3 less letters in the domain name?
- JoshuaAshton 8y agoLots of people are saying "Root domains don't allow CNAMEs" and other such things, but let's be real. Every DNS provider under the sun supports CNAME flattening.
- koshak 8y agoIn the honor of bikeshedding once a year someone writes an article on the www/non-www topic. The truth is: 1. No one cares 2. Choose one of two and stick to it 3. Care to maintain a redirect from the second option to the chosen one. Cheers!
- amingilani 8y agoI'm sure they do and I'm also sure you've heard it discussed ad-nauseam. But it was fairly new for me :)
- tabtab 8y agoDon't advertise your domain with "www", BUT make it handle it if entered that way by a user. Another advantage of "www" is that word-processors and text editors can auto-recognize it as URL if it starts with "www".