I have always been confused on the difference between the 3 most popular acronyms in web based computing – URL, URI and URN. The concept always seemed to evade me..
This post is more of a ‘talking to myself’ thing. I can almost imagine me reading this months from now, and feeling grateful that I finally wrote this down.
I started off with a good old Google search and I should say, the initial results were truly disheartening. The first results that came up was this one by damnhandy.com. Even though the intentions are true, this blog is very much misleading as it is pretty clear from the comments. The blog was followed by this and again by this and it gets pretty clear if you read all three. (A trilogy on Uniform Resources)
You could always visit the official w3c documentation. Unless you think in binary and have bytestreams for breakfast, you won’t understand much. You are better off reading couple of interesting posts in StackOverflow.
The Real Deal
So here is what I learned from the journey…
Let me talk about URI and URL first. Expanding them would be URI – Uniform Resource Identifier and URL – Uniform Resource Locator.
Both of them are used to provide details about resources ( a file, a server, a port.. ). URI is an identifier. As the name says, it identifies a resource. Let me make myself clear with some examples.
- Room 1738
See the first example, it identifies a resource ( a jpeg image with the name mojojojo ). The second example does the same, it identifies a resource. The difference between example #1 and #2, the first one gives more detail ( the location… ). But we don’t need that, all we need to do is identify the resource. A real world example would be #3, a hotel room number. There can be trizillions of Room 1738s in the planet. But all we need is an identification and that’s exactly what an URI does – an Identifier.
Moving to URL, it’s the locator. With URI, you identify the resource, and with URL, you locate the resource. In the example #1 above, we have the complete location of the resource, and that makes example #1 an URL. So, the first example is an URI and an URL – you can identify and locate the resource. But examples #2 and #3 are not URLs, they won’t help you locate the image or the hotel room. However, both these are URIs.
- Room 1738, Queen Elizabeth Hotel, Montreal, Canada
Hope you get the bigger picture. One is just an identifier, while the other one is a locator.
All URLs are URIs but all URIs are not URLs..
What then are URNs ?
The wiki page says :
A uniform resource name (URN) is the historical name for a uniform resource identifier (URI) that uses the
It’s an URI.. just that it uses the urn: scheme.. What and how an urn: scheme is implemented is totally out of scope here.. you can read on that here..
example of URN
The first example identified Umberto Eco’s ‘Baudolino’ and the second example identifies a very popular movie. It’s just the same as an URI, the only difference is that it uses the
So, that does it. Do let me know if you think what i just said is nonsense or if you want me to elaborate on any point.