Cool URIs don’t change; so what’s considered ‘cool’?
I’ve given a lot of thought, lately, to the famous Cool URIs don’t change W3C document. Should URLs end in a slash or not? Should they end in a file-extension or not? (What if you’re serving multiple formats of the same document?)
I’ve been using a trailing slash (for, admittedly, no defensible reason: the Django guys do it, and they’re cool). A trailing slash implies a directory, which doesn’t apply to serving a document—unless you think of it as a directory containing that document in a variety of formats.
Which brings us to the file extension dilemma. It seems appropriate to serve differing formats for differing extensions (e.g. HTML, PDF, XML, JSON); but, perhaps it’s best to keep the URL generic and rely on the “Accept” field in the request header to decide on the best output format.
Certainly not many tools support this kind of respect for HTTP headers, but I’m starting to believe that fully embracing HTTP is The Right Thing (TM), and it’s the direction the industry is (slowly) moving toward. (REST!)
Incidentally, screw the W3C for not including PUT and DELETE in HTML. Oh, and HTTP authentication needs some serious work. /EORant
April 11th, 2007 at 07:15
I agree that the HTTP protocol is under-utilized and somehow we need to change that. Here are some tips for URIs that I have learned as I have built websites:
Overall, a good URI should make sense if your average site visitor looks at it. It should be memorable to the point that it could be easily memorized or written down.
Just my two cents.
April 11th, 2007 at 07:42
Those are all good suggestions, lobo235. Perhaps it is best to keep file extensions out of the URL if only for the sake of—as you mentioned—keeping things short and simple for the (non-tecnical) user.
May 20th, 2007 at 18:44
Apache tacks on the trailing slash for my pages when it isn’t included.
I generally type the uri without the trailing slash in my browser and in emails, comments, etc. That is, I will do so unless I happen to be doing cut/paste and forget to remove it.