Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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?

share|improve this question
    
where in apache? which directory? –  user16287 Jun 15 '12 at 11:44
add comment

1 Answer

up vote 15 down vote accepted

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|improve this answer
    
I just added header('Content-type: text/html; charset=UTF-8');. Thanks a lot! –  Alex Aug 20 '11 at 17:23
4  
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. –  Lri Mar 23 '12 at 10:32
    
+1 for clear explanation, often wondered this and been confused. Solved with htaccess AddDefaultCharset addition –  Malachi Apr 22 '12 at 10:17
    
Thanks a lot for very good and useful explanation –  user17282 Jul 27 '12 at 12:38
add comment

protected by Community Jul 27 '12 at 15:30

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.