solovyov.net

Short urls — rev=canonical

2 min read · django, byteflow

Just yesterday my feed reader fetched Simon Willison’s article about relatively new method of url shortening.

The idea is that url shorteners in fact are not very good thing, especially from URL term of life point of view. What if tinyurl.com is going to die? A lot of URLs will appear unusable, even if their destination is still alive. And discussion gave birth to thought that it could be nice to allow sites to specify their own short urls, even using their own url shorteners.

There is site with specification (if it can be named so), in short - you should specify it in your <head>...</head> section with such link:

<link rev="canonical" href="short-url-here">

In his article Simon tells about how he has implemented rev="canonical" in it’s own blog - I like his solution for not saving anything in database. ;) But hardcoding actual types of content is not that cool, so I’ve done small Django application - revcanonical, whose task is to generate and redirect such short links.

Every url is a two strings joined by a dot - it’s a base62-coded1 identification numbers of content type and object in database. So you can use that application for any object without any configuration. README has instructions on how to install and use application.

Of course, functionality is already incorporated into Byteflow. ;-)


  1. Digits, big and small latin letters ↩︎

If you like what you read — subscribe to my Twitter, I always post links to new posts there. Or, in case you're an old school person longing for an ancient technology, put a link to my RSS feed in your feed reader (it's actually Atom feed, but who cares).

Other recent posts

Server-Sent Events (SSE), but with POST
ngrok for the wicked, or expose your ports comfortably
PostgreSQL collation
History Snapshotting in TwinSpark
Code streaming: hundred ounces of nuances