Skip to content

URIs Should Be Persistent

When you are creating a new URI for a site you are building, give it a lot of thought. You should aim to design a URI which can last forever. Of course, this is not news. Jakob Nielsen said it 10 years ago. But in the intervening 10 years, we’ve gone from URIs which typically used to look something like this:

http://www.example.com/foo.html

…which is fine, because if you go to such a link, you probably really will get HTML back, to URIs which (often) look something like this:

http://www.example.com/foo.php

…which, as I noted in a previous post, is a lie. Actually, it’s worse than a lie; it’s poor encapsulation. What happens when you come to your senses and stop using PHP? Now you URIs have to change, which means you get to either create redirects for that abomination or break every link to your site. One of the things we’ve learned from the success of Google is that the information encoded in the links between sites is nearly as important as the information on the sites itself.

The web is dynamic. It has to be, because it is too big to compile. And so the same concerns we have when writing code and dynamic languages often apply to creating a web site, whether you use a dynamic language or not. You need to choose very good names, because if you ever need to change them you will either break stuff or have a substantial job on your hands correcting every reference to the name you’ve changed, including references you don’t personally control.

So I’m going to propose a general rule, which states, "Any URI which allows an informed developer to discern the technology used to serve the result is probably broken." The resources you are serving, if they are at all valuable to the user, will probably last longer than the implementation you use to serve them.

Of course, choosing good names is hard. I read a great quote the other day:

There are only two hard things in Computer Science: cache invalidation and naming things. -Phil Karlton

Also, even after you’ve chosen a good URI, you may have to do extra work to make it functional. If routing is not built into the technology stack you’re using, you may have to implement a URL rewriter to make your persistent URIs functional. It’s worth the effort to do so.

Late update: Thank you to commentor Stecki for the link to the following article: Cool URIs don’t change, by Tim Berners-Lee. Well said.

{ 5 } Comments

  1. bobfrank | March 30, 2009 at 8:30 am | Permalink

    Umm.. what’s so bad about PHP? It’s a free and open-source standard and it runs far better than the joke that is ASP.NET.

  2. Laurent Somers | March 30, 2009 at 10:42 am | Permalink

    There’s nothing wrong with PHP, per se, but you are creating an unnecessary dependency on the underlying technology.

    Even when I’m making static html sites, I prefer creating directories with the intended name and with the file named as the default name for the underlying platform (default.html/default.aspx/index.php), exactly for this reason.

    Of course, some say that the .html ending increases the page rank in some engines, so doing rewrites to hide the true technology behind the web site may be something to take into account.

  3. Mason Wheeler | March 30, 2009 at 4:47 pm | Permalink

    I think he was wondering about the line, "What happens when you come to your senses and stop using PHP?" Apparently Craig thinks there is something wrong with PHP per se.

  4. Craig Stuntz | March 31, 2009 at 7:55 am | Permalink

    Stecki, that’s a fantastic link. Thank you!

  5. Stecki | March 31, 2009 at 7:55 am | Permalink

    Just four words: Cool URI’s don’t change (from Tim Berners Lee) http://www.w3.org/Provider/Style/URI

Post a Comment

Your email is never published nor shared. Required fields are marked *

Bad Behavior has blocked 713 access attempts in the last 7 days.

Close