Live data from Hacker News

Choosing between names and identifiers in URLs

cloudplatform.googleblog.com

81–90 of 157 posts

Re: Choosing between names and identifiers in URLs

#81
post #19

Earlier quoted context omitted.

Doing this means that: 1) there are now an infinite number of URLs for every one of your pages that may end up separately stored on various services (mitigated for only some kinds of service if you redirect to correct), 2) if the title changes the URLs distributed are now permanently wrong as they stored part of the content (and if you redirect to correct, can lead to temporary loops due to caches), 3) the URL is now…

The usual way I've seen to deal with this kind of ambiguity is by doing a 301 redirect so that bookmarks get changed and the url in the address bar is also changed. It doesn't fix external parties linking to the site with the now deprecated url but there was never anything you could reasonably do about that. > If you are going to insist upon doing this, how about doing it using a # on the page, so at least everyone h…

Minor correction, because dealing with this is a part of my job: Almost no browsers have implemented changing bookmarks in response to 301 redirects. Link has further context and some testing.

https://superuser.com/questions/151366/do-browsers-change-ur...

Re: Choosing between names and identifiers in URLs

#82
Odd that the article doesn't seem to mention the considerations of whether id's are a) globally unique and b) unguessable, and the huge difference between the URL param and directory styles - that param id is inferred from order in directory style, making all params required and missing the final one default to it equalling *.

Re: Choosing between names and identifiers in URLs

#83
post #4

Good advice. Interesting that Canonical URLs aren't mentioned. But the sheer arrogance of serving a webpage that doesn't render any text unless you execute their JavaScript really annoys me. It's not a fancy interactive web-app, it's a webpage with some text on it.

Loaded just fine with NoScript here.

Works fine when disabling javascript in Chrome developer tools too

Re: Choosing between names and identifiers in URLs

#84
post #17

Earlier quoted context omitted.

and your comment is the perfect demonstration why: when truncated, the id gets cut off before the slug.

Which is... something you don't want to happen, right?

To be fair, if you truncate a url for anything other than display, it's toast (which is why no sane person truncates URLs except for display).

Re: Choosing between names and identifiers in URLs

#85
The root of the issue here is that URLs are trying to be human-meaningful and machine-meaningful at the same time, but those requirements are fundamentally incompatible.

Humans work well with ambiguity and context. You know that when your coworker says "Bob's birthday is this weekend" you know she means her husband Bob, not Bob from accounting who nobody likes. And you even prefer that system to having an unambiguous human identifier, even a friendly one like "Bob-4592-daring-weasel-horseradish".

Machines, on the other hand, hate ambiguity and context. Every bit of context is an extra bit of state that has to be stored somewhere, and now all your results are actually statistical guesses - how inelegant!

In the early days of computing, there was no separation between the internals of the machine and its interface. If you worked on a computer, you were as much the mechanic as the driver. We got used to usernames, filenames, and hostnames because they were a decent compromise; they were meaningful enough to humans, and unambiguous enough for machines, so we could use them as a kind of human-computer pidgin.

But we don't need them anymore, and they were never really very good at either job anyway. Google's (probably accidental) discovery was that we were using the web wrong. Everyone was building web directories and portals because they thought that URLs weren't discoverable, but the real problem was that they weren't usable. Search was the first human interface to the web.

So Google's going to kill the URL, Facebook's going to kill the username, and someone (apparently not Microsoft) is going to kill the filename. There'll be much wailing and gnashing of teeth from the old guard while it happens, but someday our grandchildren will grow up never having to memorise an arbitrary sequence of characters for a computer, and I think that's a future to look forward to.

Re: Choosing between names and identifiers in URLs

#86
post #19

Earlier quoted context omitted.

Doing this means that: 1) there are now an infinite number of URLs for every one of your pages that may end up separately stored on various services (mitigated for only some kinds of service if you redirect to correct), 2) if the title changes the URLs distributed are now permanently wrong as they stored part of the content (and if you redirect to correct, can lead to temporary loops due to caches), 3) the URL is now…

The usual way I've seen to deal with this kind of ambiguity is by doing a 301 redirect so that bookmarks get changed and the url in the address bar is also changed. It doesn't fix external parties linking to the site with the now deprecated url but there was never anything you could reasonably do about that. > If you are going to insist upon doing this, how about doing it using a # on the page, so at least everyone h…

301 may be dangerous, because browsers cache them.

Suppose the client follows a link to old-slug after the slug has been changed to new-slug. The server responds 301 → new-slug. The client caches that redirect, so that if you request old-slug it will immediately take you to new-slug without querying the server.

Then the object’s slug is changed back to old-slug (perhaps the change was made in error). Now a request to new-slug produces a 301 → old-slug. This likewise is cached, and a client may new be stuck in an infinite redirect loop.

I’m not sure if this is actually what browsers do; they might detect the loop and decide to throw away their cached redirects. I haven’t tested it; but I wouldn’t count on it.

Re: Choosing between names and identifiers in URLs

#87
Something was bugging me about this, but I had to think hard to figure it out.

The article is largely based on a misguided premise: the idea that URLs should be conceptualized as either names or identifiers. URLs are neither: they are addresses of web pages. The things located at the URL may have names or identifiers, but by design of the web the stuff located at an address is mutable while the address is immutable.

This is an important point because it breaks the analogies to books or bank accounts. A physical copy of Moby Dick is a thing that may be located at a given address, or not. The work of fiction "Moby Dick" has an ISBN number, but the ISBN number is metadata, not an address. A bank account number is also metadata, not an address.

So I get the feeling that URLs should be conceptualized as addresses first and foremost. This isn't a magic bullet for the problem the blog post addresses (how to design URLs) but I think it gives some perspective:

* If the "thing" at the URL will always be conceptually the same "thing", but its name or other metadata may change, it makes sense to assign that thing a unique identifier and use this as part of the URL. (Because the thing with this ID will always be found at this address.)

* If the name of the stuff located at the URL is never going to change, it makes sense to use the name as part of the URL. (Because the stuff with this name will always be found there.)

* "Search results" as discussed in the blog post are a special case of the previous point: if a URL will always contain search results for a certain query, it makes sense to use the name of the query as part of the URL.

* There are also URLs that fall outside the name or identifier paradigms. http://www.ycombinator.com/about/ is the address of a bunch of stuff, which is not necessarily a single coherent thing with either an ID number or a name, but is a very reasonable address at which some content may be located.

Maybe this is all obvious, but to me it really helps think about the issue whereas the blog post confused some things for me, so I thought I'd share.

Re: Choosing between names and identifiers in URLs

#88
post #85

The root of the issue here is that URLs are trying to be human-meaningful and machine-meaningful at the same time, but those requirements are fundamentally incompatible. Humans work well with ambiguity and context. You know that when your coworker says "Bob's birthday is this weekend" you know she means her husband Bob, not Bob from accounting who nobody likes. And you even prefer that system to having an unambiguous…

> The root of the issue here is that URLs are trying to be human-meaningful and machine-meaningful at the same time, but those requirements are fundamentally incompatible.

The TLDR of TFA is that an API can support both human-meaningful and machine-meaningful URLs.

Re: Choosing between names and identifiers in URLs

#89
post #85

The root of the issue here is that URLs are trying to be human-meaningful and machine-meaningful at the same time, but those requirements are fundamentally incompatible. Humans work well with ambiguity and context. You know that when your coworker says "Bob's birthday is this weekend" you know she means her husband Bob, not Bob from accounting who nobody likes. And you even prefer that system to having an unambiguous…

Apple are the ones to kill the file name, with iOS.

Re: Choosing between names and identifiers in URLs

#90

Earlier quoted context omitted.

I understand the frustration but you also understand that the vast majority of individuals render JS on the page and do not use text only browsers. It’s not worth the time to appeal to such a minority share of internet users.

Your argument holds for web apps where it might be extra work to do progressive enhancement. But this is literally a webpage of text. It is more work to get JS involved. Humans using off the shelf browsers aren't the only ones who consume webpages.

> But this is literally a webpage of text. It is more work to get JS involved. Humans using off the shelf browsers aren't the only ones who consume webpages.

Sort of, the contents of the post are in a database somewhere. It's not like someone uploaded a .html page to Blogspot and they converted it into JS. The JS makes it easier for users to customize templates.

The main reason you'd want to avoid doing something like this is that the Googlebot would penalize you, but somehow I doubt Google is concerned with that.

That said, it has a version that seems to work fine (I turned off JS and it renders as expected.

Post reply on HN