Character set not specified in HTTP headers error

25,141

It is referring to Response Headers and not document body ("Content-Type tag").

If you check Response Headers of your page with any HTTP Debugger (for example, Net panel of Firebug for Firefox, or similar tab of Developer Tools in Google Chrome/Internet Explorer/Safari/Opera), you will see this line:

Content-Type: text/html

At the same time, if you check the same for this page, you will see:

Content-Type: text/html; charset=utf-8

Page Speed is referring to the missing part. Having correct character set present in headers will indeed speed up rendering the page a bit. With incorrect charset specified in response header (or no character set at all) browser needs to scan/interpret the page until it find the correct character set declaration (the <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> line) and then re-start the rendering process if character set is different from browser's default setting.

The performance penalty is not big at all -- for user it is unnoticeable unless really old/slow hardware is in use (although it differs for each browser and browser version). Maybe there are some other "penalties" that are directly related to this, but I personally unaware of them.

Fixing: If you generate this header yourself (in your PHP script), then you need to alter it to include charset as well. If your script does not do such header manipulations, then it is server misconfiguration issue.

Share:
25,141
Alex
Author by

Alex

(my about me is currently blank)

Updated on September 18, 2022

Comments

  • Alex
    Alex over 1 year

    When testing this page with Page Speed, I get the a Specify a character set error:

    The following resources have no character set specified in their HTTP headers. Specifying a character set in HTTP headers can speed up browser rendering.

    The Content-Type tag is present and the page was saved with UTF-8 encoding as well, so where is the error coming from?

    • Admin
      Admin almost 12 years
      where in apache? which directory?
  • Alex
    Alex over 12 years
    I just added header('Content-type: text/html; charset=UTF-8');. Thanks a lot!
  • Lri
    Lri about 12 years
    You can also view the response headers with curl --head $url. The default charset can be specified in Apache by adding AddDefaultCharset utf-8 to a config file like .htaccess.
  • Malachi
    Malachi about 12 years
    +1 for clear explanation, often wondered this and been confused. Solved with htaccess AddDefaultCharset addition
  • Daniel Springer
    Daniel Springer over 7 years
    Shouldn't <meta charset="utf+8"> suffice?