Winona
Winona

Reputation: 51

Specifying a character set in HTTP headers

When using Google PageSpeed tester, I get the following:

The following resources have no character set specified in their HTTP headers. Specifying a character set in HTTP headers can speed up browser rendering.
http://www.ntainc.com/

I have searched everywhere, and can't seem to figure out why it isn't "reading" my charset. I have it listed in the html document header:

<meta charset="utf-8">

And in my web.config file:

<?xml version="1.0" encoding="UTF-8"?>

and there is an .htaccess file:

AddDefaultCharset utf-8

I believe our server is an IIS. What am I missing?

Upvotes: 2

Views: 10363

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 597941

The warning is referring to the HTTP Content-Type header. It is being sent by your webserver to the client like this:

Content-Type: text/html

It needs to be sent like this instead:

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

You need to check your webserver configuration. Your .htaccess addition should be adding the charset attribute to the header, but apparently is not. So either you put it in the wrong .htaccess file, or the server is ignoring it.

The fact that your HTML contains a <meta charset> tag is irrelevant to the warning, as the HTML is just arbitrary data inside of the HTTP response body (though it does allow an HTML5-enabled client to process your UTF-8 encoded HTML correctly).

Your web.config charset is irrelevant, as it is only interpreted by your webserver, not a client.

Upvotes: 4

Related Questions