Signs that the response depends on the request#
- The page's HTML or script URLs differ between the reporter's capture and the maintainer's.
- The response carries
Vary: User-Agent,Vary: Accept-LanguageorVary: Sec-CH-UA-Mobile, telling caches that the response depends on that header. MDN:Vary - The site serves a separate mobile site, a "legacy" bundle for older browsers, or a bot challenge.
- The bug follows the browser, not the account: a colleague with the same browser sees it, and a different browser on the same account does not.
What the browser sends#
We loaded a page from a local server in Playwright's Chromium and logged the request headers. Over http://localhost, a secure context, the request carried User-Agent and the default low-entropy client hints, such as:
sec-ch-ua: "Chromium";v="153", "Not_A Brand";v="8"
Loaded from the same server over the machine's network address, an insecure origin, the request had no sec-ch-ua header at all. Chromium sends client hints only to secure origins. A staging server reached over plain http on an internal address therefore gets fewer headers than production does over https. MDN: User-Agent Client Hints
Firefox and Safari send a User-Agent header and no Sec-CH-UA headers.
Compare the two responses#
- From the reporter: the failing document's request headers and response headers, from the Network panel, with credentials removed.
- From the maintainer: the same request, replayed with the reporter's headers. Copy as cURL gives the reporter's full header set; the curl replay guide covers editing it.
- Replay again with only the
User-Agentheader changed back to the maintainer's, then onlyAccept-Language, then only the client hints. The header whose change flips the response is the one the server uses.
curl -sS -o reporter.html -H 'User-Agent: <reporter string>' -H 'Accept-Language: pt-BR' https://example.test/
curl -sS -o mine.html -H 'User-Agent: <my string>' -H 'Accept-Language: pt-BR' https://example.test/
diff <(grep -o 'src="[^"]*"' reporter.html) <(grep -o 'src="[^"]*"' mine.html)
Replay in the browser with the same headers#
Playwright's context options set the user-agent string and locale, which also sets Accept-Language:
const context = await browser.newContext({
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.1 Safari/605.1.15',
locale: 'pt-BR',
});
Changing the user-agent string does not change the engine, so this replays the server's decision, not the other browser's behavior. That is exactly what you want to test here.
Worked example: a legacy bundle for a new browser#
This example is fictional. Users of one Chromium-based browser report that the checkout page's address autocomplete is missing. In Chrome it works.
The two document responses differ: the affected browser's HTML loads app.legacy.js. The build served a legacy bundle, without the autocomplete feature, to any user-agent string it did not recognize. The affected browser's string contained its own brand and not Chrome/. Replaying with that string in Playwright's Chromium loaded the legacy bundle and reproduced the missing autocomplete. The fix switched the bundle choice to feature detection in the browser instead of user-agent matching on the server.
Questions#
Can a CDN cache the wrong variant?
Yes, if the origin varies the response by a header but does not say so in Vary, or the CDN ignores it. One user's variant is then served to others. Compare the CDN's cache status header on both responses.
Do I need the reporter's exact user-agent string?
Use it as reported. Small differences, such as an OS version or a brand name, are often what a server's matching rule reads.
Is this a privacy problem to collect?
A user-agent string is not personal data on its own, but combined with other details it narrows down a user. Collect what the reproduction needs.
Return to reproducing what someone else saw for the other layers a replay needs.