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.55k stars 2.68k forks source link

Google Bot Scan no longer detect as mobile #833

Closed BrianEARTH closed 4 years ago

BrianEARTH commented 4 years ago

Issue description Hi All, I have a strange issue for about 5 days. I use Mobile detect for a while on my old php based sites. Up to those days, on Google Admin tools, when i check a page, it answers : mobile compatible (as google scroll as smartphone) and that's ok. But now .. It no longer do that !! So I put the latest version of MobileDetect.. Still the error.. I made a test page (very simplified), just with an echo : 'mobile' or 'not mobile' and it appears as not mobile !! I try to use the google mobile test page : it correctly detect mobile, as my Samsung or Iphone do ... So I guess there is a pb with the detection of GG Bot ... When I look into apache log, I can't see any difference, but I'm not expert enough to conclude something...

Do any of you have the same pb ? With Thanks

Brian

User-Agent(s) Google Bot log : [02/Apr/2020:14:54:02 +0200] "GET /css/style.css HTTP/1.1" 200 3485 "My Site URL deleted for example" "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.92 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" (if corrected detected it would have ask for styleP.css (the Mobile version of my css ..))

Suggestions May be try a simple test page and check difference between the crawl from the main google admin tool page (you know when you ask gg to check for your page and indexe or reindexe your page) and the crawl from the google mobile test page ? Thx

BrianEARTH commented 4 years ago

I think I've found my answer lol ! Seems that my fellow change some cache options on the server ... So I added :

<?php header("Vary: User-Agent, Accept");

On my page and it's ok ....

So there must be a cache pb, that we need to solve.

That can help some ;)

Thx