7

I am trying to use PageSpeed Insights in Google Search Console for Weebly/Square website and getting an error:

Lighthouse returned error: NOT_HTML. The page provided is not HTML (served as MIME type )

It worked for me at the beginning (I tested 2-3 times). I resized some images and tried again. Getting this error since then.

Square's support states it's not on their side.

Julia S
  • 71
  • 1
  • 1
  • 2
  • We need a fair bit more info here, how did you resize the images, did you use a plugin of some description that is within the site itself? Secondly what MIME type is the page being served as? Do you know how to check what headers you are receiving? It **is** their side if you host it with them so call them again and be forceful, incorrect MIME types is a config issue, even if you caused it they should be able to help if they host it, or at least help you with checking what MIME type you are sending and how to roll the site back to before it broke. – GrahamTheDev Mar 04 '21 at 08:25
  • Thank you, @GrahamRitchie for getting back to me! We manually resized and replaced the images. Headers we are receiving: Request URL: https://www.rustichappyplace.com/ Request Method: GET Status Code: 200 OK Remote Address: 199.34.228.164:443 Referrer Policy: strict-origin-when-cross-origin Cache-Control: no-cache, private Connection: keep-alive Content-Encoding: gzip Content-Type: text/html; charset=UTF-8 Date: Fri, 05 Mar 2021 14:01:02 GMT – Julia S Mar 05 '21 at 14:07
  • Hmm not sure exact cause but if I run https://www.rustichappyplace.com/ I get the "document cannot be reliably loaded" error that lighthouse tends to throw if a resources is blocked to robots by mistake. However you can audit the site using Developer Tools (F12) -> "Audit" to get speed data. (there is definitely something with the site that isn't right but I can't spot it as it won't run on web.dev/measure but will run on GTMetrix. The other thing might be that it doesn't like "Google Bots" or there is something about mobile that causes an issue.) – GrahamTheDev Mar 05 '21 at 16:02
  • Thank you for your answer! I will try to contact square support with that and see, if they can tweak something on their side to make it work. – Julia S Mar 05 '21 at 16:29

2 Answers2

8

Lighthouse returning NOT_HTML can have at least three causes:

  1. The page is really served as text/plain or without any valid Content-Type, potentially because of browser or bot detection.

    You might be able to reproduce this by making a request with the same User-Agent as Lighthouse:

    curl -IA "Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.175 Mobile Safari/537.36 Chrome-Lighthouse" 'https://www.rustichappyplace.com/'

  2. The webserver supports HTTP/2 or QUIC, but doesn't implement the protocol exactly as Lighthouse expects it, causing the Content-Type to be misdetected.

    You should be able to reproduce the error in the newest Google Chrome or Chromium Nightly browser. In that case there is little you can do except asking your hoster to disable these features or to update the server software.

  3. Lighthouse has a bug that is triggered because of some feature the web server uses.

    Currently (March 2021) Lighthouse on Google PageSpeed Insights seems to have a bug that produces NOT_HTML in some constellations when HTTP/2 Early Hints are activated in the web server. I've had a similar problem today and found that disabling H2EarlyHints in Apache 2.4.46 prevented the issue.

    If your hoster uses that feature to accelerate page loading, ask them to disable it for now.

Community
  • 1
  • 1
cg909
  • 2,247
  • 19
  • 23
0

If you are using Cloudflare. Sign in to the Cloudflare dashboard. Go on speed in the left panel. Click Optimization. Click on the other tab. Switch off the last option "Mobile Redirects." Done