WOFF2 - HTTP Content-Type response header suggestion
Asked Answered
G

2

7

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

Geisha answered 16/2, 2015 at 15:55 Comment(0)
C
23

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!

Cognate answered 7/4, 2015 at 12:42 Comment(0)
V
0

In .htaccess AddType should be in mod_mime.c module

<IfModule mod_mime.c>
AddType application/woff2 .woff2
</IfModule>
Vonnievonny answered 4/2, 2021 at 15:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.