serbanghita / Mobile-Detect

Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
http://mobiledetect.net
MIT License
10.52k stars 2.67k forks source link

Google SERP links open as the mobile version #945

Closed joomlabeat closed 10 months ago

joomlabeat commented 10 months ago

I discovered an issue and I am not sure where to look for finding a solution. Using mobile detect - I deliver slightly different content/layouts among desktop and mobile devices for the same URLs.

Recently, I started finding links of the site in Google SERPs using a desktop computer, that when clicked they will go to the page, which will display the Mobile version of the layout/content. This may include also displaying images that are otherwise full-width in the screen, to be displayed in smaller sizes (resized for mobile screens). However, doing a simple page reload, it will load the normal desktop layout of the page (no cache clearing - just simple page reload).

The URL remains the same and has no special parameters - nothing. At the same time, if I try to go to the same URL directly, it will load immediately the desktopug version. The same also if I use any backlink that is manually created. It's the links from Google SERPs (at least some of them - haven't check them all) that will go to the page and display first the mobile version.

I have no clue what mechanism could be involved here and why this is happening. Also, it's not easy to find anything similar on the web - Did some googling, found some issues with mobile sites with separate URLs on Google Support Forums, but those cases are not what I am experiencing.

I thought to start from here... since the results I am getting are produced by using mobile_detect - Meaning that what the page will display depends on the library - so maybe here there are other users that might have experienced something similar.

Have you checked your SERPs links recently? Have you noticed anything like the my issue? Not sure if it's a bug - or if it's something new on the way Google is handling those links - could be results created by the "Mobile-First thing"... and Google could be passing data to the page e.g. like that the links come from a mobile device... ???

joomlabeat commented 10 months ago

Hmmm... I am very confused with this... The same SERP links on Firefox seem to open fine. The issue occurs on Chrome. I also have to say that I am using CloudFlare. I deep cleared caches, totally disabled CloudFlare for some time, tried through another new user on my mac, as a guest user on Chrome... - still certain SERP links take me to the "Mobile" version of the page when using Chrome. Trying all kind of things, in order to be able to identify patterns and/or reproducable steps and reach to some conclusions... but still in the fog.

joomlabeat commented 10 months ago

I added some debug code on the online website, disabled everything on my end that might create cached content, disabled CloudFlare completely, cleared all caches on the website, changed HTTP headers, cleared all caches on my browser and computer, including DNS, even changed my DNS servers that connect me to the internet, closed browser, restarted computer.

Reminder: The issue is when visiting the pages via a Google SERP Link. Then tried with Google Chrome, Safari and Firefox. Safari, Firefox work fine. Chrome persists in serving a cached of the mobile version - even when I use Chrome via a new Mac OS user, as a guest, via incognito etc. Once the page is reloaded in the browser it loads the right version. Moreover, the debugging code isn't triggered with the first load coming from Google SERP links. It only gets triggered when reloading the page. Using the other browsers, the debugging code is triggered everytime. I can not find a way to clear those cached pages.

The above findings make think that there might be some kind of new mechanisms are being tested, implemented by Google, for delivering a cached version of the website via Google index or something, to help with instant/faster loading. It also seems that this mechanism prefers mobile versions. Certainly this is not a definite conclusion.

If that's the case and there is no any bug in what Google possibly tries to implement, then this could be an issue for the current status of mobile_detect.

joomlabeat commented 10 months ago

One more thing... I used various different Search Engines with Chrome and it works well. So it seems to be something related with Google Search + Chrome.

joomlabeat commented 10 months ago

OK just found what causes the above behavior: https://developers.google.com/search/docs/appearance/signed-exchange

Also this: https://community.cloudflare.com/t/automatic-signed-exchanges-sxgs-beta-launch/312634

joomlabeat commented 10 months ago

Not a Mobile-Detect bug