Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fix the Lighthouse returned error: NOT_HTML. The page provided is not HTML (served as MIME type ) error for square/weebly website?

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.

like image 912
Julia S Avatar asked Mar 04 '21 00:03

Julia S


1 Answers

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.

like image 115
cg909 Avatar answered Oct 18 '22 00:10

cg909