How does Chrome's "Request Desktop Site" option work?

Google ChromeMobile

Google Chrome Problem Overview


For iOS google chrome, when a user hits the "Request desktop site" button what does the browser do to try to bring up a desktop site? I imagine some sort of header on the request that sites are looking for, or something similar?

Google Chrome Solutions


Solution 1 - Google Chrome

I think the only difference is the User-Agent: header in the request.

Here are the User-Agent headers sent by Chrome on my Android device:

Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.45 Safari/535.19

Notice the word "Mobile' in the first one, and also the mention of Android system and device. Checking these, I see that it also provides false information - namely X11 and x86_64 - to closely match the value sent by the Desktop Linux version of Chrome.

Solution 2 - Google Chrome

Just wanted to point out that Chrome now not only changes the User-Agent but also ignores the original viewport meta tag if you "Request Desktop Site". Thus it won't be necessary to sniff the User-Agent anymore and you can rely on the viewport change as most responsive sites will automatically do. See this Change for further reference.

Solution 3 - Google Chrome

One other slight difference is that the request appears to have been to the last intentionally entered URL before any re-directors moved it. For example:

Given: somesite.com sniffs the agent, sees Android, and does a document.location += "/m";

Then: the browser will have a URL of somesite.com/m

But: if you "Request desktop site" it will change the User-Agent and re-request from somesite.com

Unless: you had gone directly in on the mobile URL of somesite.com/m in the first place, in which case it just reloads somesite.com/m.

I would expect that this works with HTTP 301 and 302 redirects, I know it works with document.location changes (at least as described), and would speculate that it works with <meta> refreshes.

Solution 4 - Google Chrome

This javascript snippet will effectively do the same :

function requestDesktopSite() {
    document.getElementsByTagName('meta')['viewport'].content='min-width: 980px;';
}

<button onclick="requestDesktopSite()">Request Desktop Site</button>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionbutallmjView Question on Stackoverflow
Solution 1 - Google ChromedshView Answer on Stackoverflow
Solution 2 - Google ChromeThomasView Answer on Stackoverflow
Solution 3 - Google ChromeJason MillerView Answer on Stackoverflow
Solution 4 - Google Chrome10usView Answer on Stackoverflow