It’s been a decade since Tim Berners-Lee wrote Hypertext Style: Cool URIs don’t change, the first contribution to what is still not a very extensive literature on designing namespaces for the web. Recently, when I made the suggestion that a blog engine ought not produce URLs that end with .aspx, I was asked: “Why does it matter?” For me it boils down to two reasons:

  1. Futureproofing
    A blog posting is, in theory, a permanent artifact. You’d like its URL to remain constant. Sometimes, of course, change is unavoidable. URLs aren’t digital object identifiers, and for most web resources, there’s no way to insulate yourself from an ownership change that results in a domain name change. But you don’t want to subject yourself to avoidable change, and file extensions fall into that category. Last year foo.asp, this year foo.aspx, next year something else, the only meaningful part of the name is foo. The technology that produces the name, never mind the version of that technology, is a variable that need not, and should not, be exposed. If links are pointing to foo.asp, and your upgraded blog engine produces foo.aspx, you broke those links. That’s unnecessary and avoidable.

  2. Style
    Names without extensions are cleaner and simpler. Why does that matter? I guess if you think of URLs as constructs generated by machines for machines, then it doesn’t, because machines don’t care about style. But I believe that even when they’re machine-generated, URLs are for people too. We read, cite, and exchange them. Their structure and content conveys meaning in ways that warrant thoughtful analysis. Elements that don’t convey meaning, and that detract from clarity, should be omitted.

The Strunk and White Elements of Style for the literary form that is the web’s namespace hasn’t really been written yet, but Tim Berners-Lee’s 1998 essay belongs in that genre. So does the Richardson and Ruby book RESTful Web Services which, as I noted in my review, recommends that URIs use forward slashes to encode hierarchy (/parent/child), commas to encode ordered siblings (/parent/child1,child2), and semicolons to encode unordered siblings (/parent/red;green). We can, and we should, think and act in principled ways about the web namespaces we create.

I guess I’m extra-sensitive to the .aspx thing now that I work for Microsoft, because I know that to folks outside the Microsoft ecosystem it screams: We don’t get the web. It’s true there are plenty of .php and other extensions floating around on the web. But non-Microsoft-powered sites are far more likely to suppress them than are Microsoft-powered sites, because you have to go out of your way to get IIS and ASP.NET to do that.

Happily, that’s changing. The URL rewriting capability that’s long been standard in Apache, and is integral to modern web frameworks like Rails and Django, is coming to ASP.NET. From Scott Guthrie’s introduction to the ASP.NET MVC Framework:

It includes a very powerful URL mapping component that enables you to build applications with clean URLs. URLs do not need to have extensions within them, and are designed to easily support SEO and REST-friendly naming patterns. For example, I could easily map the /products/edit/4 URL to the “Edit” action of the ProductsController class in my project above, or map the /Blogs/scottgu/10-10-2007/SomeTopic/ URL to a “DisplayPost” action of a BlogEngineController class.

I hope that cool URIs will become the default for Microsoft-powered websites and services. Meanwhile, there are a variety of add-on URL rewriters for IIS that can streamline and normalize web namespaces. I wish they were used more extensively.