User agents and adaptive serving
Adaptive serving means returning different markup, assets, or experiences based on the requesting client, often keyed on the user agent. It can deliver lighter pages to constrained devices, but UA-based branching is brittle: strings drift, edge cases proliferate, and a wrong guess degrades real users. Client hints and feature detection are the more durable approach.
What this means
Adaptive serving is the practice of changing what you send based on the client: a slimmer page for a low-end device, different image formats, or a tailored layout. When the decision is made from the user agent, the server inspects the UA string and branches.
The appeal is real, especially for performance on constrained devices. The danger is equally real: user-agent strings are inconsistent, frozen, and reduced over time, so branching on them ages badly and breaks for clients you did not anticipate.
Caching and correctness pitfalls
If a response varies by user agent, caches must account for that variation or they will serve the wrong variant to the wrong client. Getting Vary headers and cache keys right is subtle, and a mistake can pin a mobile variant to desktop visitors or vice versa.
A safer modern path is to adapt on explicit signals: User-Agent Client Hints for device characteristics, and feature detection for capabilities. These ask the client what it actually supports instead of inferring it from a string that is increasingly reduced for privacy.
- UA branching ages badly as strings are frozen and reduced
- Per-UA responses complicate caching and Vary handling
- Client hints and feature detection are more durable signals
How it appears in analytics and logs
When responses change based on the user agent, the same URL can return different bytes to different clients. In logs this shows up as UA-correlated variation in payload size, status, or rendered features rather than a single canonical response.
Diagnostic use case
Decide whether to vary responses by user agent, understand the caching and correctness pitfalls, and choose client hints or feature detection where they fit better.
What WebmasterID can help detect
WebmasterID records the user agent of each request server-side, so you can see which UA families hit which variants and confirm adaptive rules are firing on the clients you intend, without fingerprinting visitors.
Common mistakes
- Branching critical layout on UA substrings that later disappear.
- Serving per-UA variants without correct Vary/cache keys.
- Using UA sniffing where feature detection would be accurate.
Privacy and accuracy notes
Adaptive serving keys on the request user agent, a device/browser hint, not a person. Any audience grouping it produces is coarse and must not be treated as individual identification.
Related pages
- User-Agent Client Hints
User-Agent Client Hints are HTTP headers (the Sec-CH-UA family) that let a site request specific browser, platform, and version detail rather than reading it all from one passive string. They underpin UA reduction: the raw user agent is shrinking, and finer detail moves to opt-in hints. This page explains the model.
- User agents vs feature detection
Feature detection checks at runtime whether a specific capability (an API, a CSS feature) is available, rather than inferring it from the user-agent string. It is more reliable than user-agent sniffing because it tests the actual environment instead of a self-reported, spoofable label. The user agent still has narrow, legitimate uses, but capability decisions should rest on feature detection.
- User agent sniffing pitfalls
User-agent sniffing means changing site behaviour based on substrings in the User-Agent header. It is fragile: it misfires on new or unexpected browsers, breaks as user agents are reduced, and is easily defeated by spoofing. Feature detection and Client Hints are more robust approaches for most cases.
- Website observability
See which user-agent families hit which response variants server-side.
Sources and verification notes
- MDN — Browser detection using the user agentDocuments pitfalls of UA-based serving and recommends feature detection / client hints.
Last reviewed 2026-06-24. Facts are checked against primary/official sources where available; uncertain specifics are marked “Data not yet verified” rather than guessed.