Designing Effective URLs: Understanding URI, URL, and URN
This article explains the concepts and differences of URI, URL, and URN, describes their hierarchical relationship, outlines URL components, discusses Data URI syntax, presents best‑practice guidelines for stable and user‑friendly URL design, and provides real‑world examples such as Flickr API URL patterns.
Uniform Resource Identifier (URI) is the top‑level concept for naming resources on the Web; URLs (Uniform Resource Locators) and URNs (Uniform Resource Names) are sub‑categories of URI, with URLs locating a resource and URNs providing a persistent name.
The article details the three parts of a typical URL: the scheme (protocol), the host (optionally with port), and the path to the specific resource. It notes that the scheme and host are mandatory, while the path may be omitted.
URNs follow the syntax URN:NID:NSS , where NID is a namespace registered with IANA and NSS is a namespace‑specific string. An example is the ISSN expressed as a URN: urn:issn:1234-1231 , which can be placed in HTML metadata like <meta name="Identifier" scheme="URN:ISSN" content="1234-1231"> .
Data URIs, defined by RFC 2397, embed small files directly in documents using the syntax data:[<MIME-type>][;base64],<data> . Their advantages include reducing HTTP requests and bandwidth for tiny assets, while disadvantages involve lack of caching, larger encoded size, and potential security concerns.
Good URL design principles are presented: keep URLs short, memorable, and readable; avoid changing URLs whenever possible; use hyphens instead of underscores; omit file extensions; avoid embedding volatile information such as dates, author names, or status flags; and treat the URL as a stable interface similar to a brand name.
The article also covers technical details such as handling hash fragments (the part after ‘#’) for client‑side navigation, the behavior of onPushState and onReplaceState in the History API, and proper use of HTTP redirect status codes (301, 302, 307) for moved resources.
Real‑world examples include Flickr’s image and page URL patterns, showing how farm‑id, server‑id, photo‑id, secret, and size suffixes compose image URLs, and how short URLs are generated using Base58 encoding (e.g., http://flic.kr/p/abc123 ).
Additional recommendations cover domain choice (prefer .com for international sites, but country‑code TLDs are acceptable for localized content), the importance of a stable root section in the URL hierarchy, and the use of namespace‑based paths for scalable URL structures.
Finally, the article advises using standard authentication and session mechanisms instead of embedding credentials in URLs, providing proper caching headers, and ensuring that any URL changes are handled with standard redirects to preserve link integrity.
Architecture Digest
Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.