Fundamentals 25 min read

Understanding URI, URL, and URN: Design Principles and Best Practices

This article explains the concepts, differences, and hierarchical relationships of URI, URL, and URN, discusses common pitfalls and design guidelines for stable and user‑friendly web addresses, and provides practical examples such as Data URI syntax, Flickr API URL patterns, and HTTP redirection strategies.

Architect
Architect
Architect
Understanding URI, URL, and URN: Design Principles and Best Practices

URI, URL and URN

URI (Uniform Resource Identifier), URL (Uniform Resource Locator) and URN (Uniform Resource Name) are standardized ways to identify, locate and name resources on the Web. URI is the top‑level concept; URL and URN are sub‑categories of URI.

URI : a generic identifier that can be a locator, a name, or both.

URL : a URI that provides a means to locate a resource (its address).

URN : a URI that names a resource without specifying its location.

URNs are persistent identifiers (e.g., ISBN, ISSN) while URLs can change when the resource moves.

URL

A URL describes an information resource using a string that includes a protocol, host (optionally a port), and a path to the resource. The three parts are separated by "://" and "/". Because URLs embed location information, they must be updated when the resource moves.

URN

URNs follow the URI syntax URN:NID:NSS , where NID is a namespace identifier registered with IANA and NSS is a namespace‑specific string. Example: urn:issn:1234-5678 represents an ISBN‑style identifier.

URI

A URI is a simple string that uniquely identifies a resource, typically composed of a naming mechanism, a host name, and a resource‑specific path. URL is a subset of URI.

Data URI (an immature technique)

Data URI, defined in RFC 2397, embeds small files directly in a document using the syntax:

data:[<MIME‑type>][;base64],<data>

Advantages include fewer HTTP requests and reduced bandwidth for tiny assets; disadvantages are lack of caching, larger encoded size, and security concerns.

Designing a Good URL

Good URLs should be easy to remember, short, readable, predictable, stable, and reflect the site’s structure. Avoid changing URLs whenever possible; if a change is unavoidable, use proper HTTP redirects (301, 302, 307) to preserve link equity.

Use simple, memorable domain names (prefer .com for global sites).

Prefer hyphens over underscores.

Keep URLs under ~80 characters.

Do not expose implementation details (e.g., cgi-bin, .php) in the path.

Separate concerns: use content negotiation or proxying instead of file extensions.

Root Sections and Namespaces

The top‑level sections of a URL are valuable; decide them early and keep them stable. Namespaces (e.g., https://github.com/pallets/flask/issues ) help organize resources without deep nesting.

Query Strings, Fragments, and Case Sensitivity

Query strings are useful for sorting and filtering (e.g., ?sort=alpha&dir=desc ). The fragment identifier (the part after # ) points to a position within the page, is not sent to the server, and can be changed via location.hash without reloading.

Practical Examples

Flickr API URL Rules

Flickr image URLs follow patterns such as:

http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}.jpg

Size modifiers (s, t, m, -, z, b, o) are appended before the file extension to request different image dimensions.

Webpage URLs use user IDs or custom names, e.g., http://www.flickr.com/photos/{user-id}/ for a photostream or http://www.flickr.com/photos/{user-id}/{photo-id} for an individual photo.

Short URL Service

Flickr also provides short URLs using Base58 encoding: http://flic.kr/p/{base58-photo-id} , which removes ambiguous characters.

Conclusion

URI/URL design is a core part of Web UI and should be treated with the same care as branding. Stable, human‑friendly URLs improve usability, SEO, and long‑term maintainability.

Best PracticesWeb ArchitectureHTTPURLDesignURIURN
Architect
Written by

Architect

Professional architect sharing high‑quality architecture insights. Topics include high‑availability, high‑performance, high‑stability architectures, big data, machine learning, Java, system and distributed architecture, AI, and practical large‑scale architecture case studies. Open to ideas‑driven architects who enjoy sharing and learning.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.