WOFF2 - HTTP Content-Type response header suggestion

ummahusla picture ummahusla · Feb 16, 2015 · Viewed 7k times · Source

I'm doing some website optimisations using PageSpeed. I faced a next suggestion:

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://localhost:8892/.../FocoBold.woff2
http://localhost:8892/.../FocoRegular.woff2
http://localhost:8892/.../GTblack.woff2

I've instantly started google and found a relevant answer on StackOverFlow.

I've added next line to .htaccess but it didn't worked for me.

AddDefaultCharset UTF-8

Next thing I've tried, but still no results.

AddType font/woff2 .woff2

Can anyone help me with that?

Thank you in advance

Answer

Mark Bradley picture Mark Bradley · Apr 7, 2015

I was having the same problem.

I think that is misreporting the underlying cause which is not so much a lack of definition of the charset, but a lack of definition of the . Without that's being defined, it / most browsers assume what is being sent back is text/html, where, indeed, no charset has been defined, especially as the file will contain "non-standard" (ASCII!) chars.

My solution (it may not work if your environment is significantly different, such as not allowing in .htaccess files) was to add the following to the .htaccess in the relevant root of the site being served:

AddType application/x-font-woff2 .woff2

(Found this resource)

Worked for me!