So You Want to Define a Well-Known URI
The author of the Well-Known URI specification offers expert guidance on their proper application, detailing when they are most effective and, crucially, when they are the wrong tool for the job. This deep dive into a core web standard is popular on HN for its authoritative insights into avoiding common implementation pitfalls and designing robust web protocols.
The Lowdown
Mark Nottingham, a co-author of the Well-Known URI specification and current Designated Expert for its registry, shares his insights and best practices for defining and using Well-Known URIs. His advice goes beyond mere compliance, focusing on effective application and common pitfalls based on his extensive experience coaching protocol designers.
- What they're for: Well-Known URIs are best suited for situations where a client already knows a site and needs to efficiently discover something site-wide, such as
robots.txtfor crawler policies or achange-passwordendpoint. - When they're not: They are not a badge of legitimacy or a shortcut; they shouldn't be used as a URL shortener if a full URL can be transmitted, as this locks deployments into a restrictive 1:1 service-to-site relationship.
- Discovery mechanisms: A common pitfall involves the fuzzy reality of hostname discovery. Designers must carefully consider the scope of user interaction and ensure reliable hostname resolution, especially when protocols aren't strictly 'web' focused.
- Content metadata: Using Well-Known URIs for content metadata can be complex, particularly for sites hosting multiple publishers. This creates a tradeoff between convenience and granularity, often requiring parallel metadata mechanisms.
- Other considerations: Protocols with pre-existing fixed root locations should have a clear transition plan to Well-Known URIs. Designers must explicitly enumerate all relevant URI schemes, not just
httpandhttps, and ensure proper registration of their chosen well-known locations.
In essence, Nottingham emphasizes that Well-Known URIs solve a very specific problem. Protocol designers should thoroughly understand this problem and the associated complexities before opting for a Well-Known URI, rather than using it as a default or for perceived legitimacy.