WOFF2 - Content-Type HTTP Response Header Proposal

I am doing some website optimization using PageSpeed . I came across the following sentence:

The following resources do not have the character set specified in the HTTP headers. Specifying the 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 ran google instantly and found the corresponding answer in StackOverFlow.

I added the following line to .htaccess , but this did not work for me.

 AddDefaultCharset UTF-8 

The next thing I tried, but still no results.

 AddType font/woff2 .woff2 

Can anyone help me with this?

Thank you in advance

+7
.htaccess woff
source share
1 answer

I had the same problem.

I think that pagespeed incorrectly reports the main reason, which is not so much the lack of an encoding definition, but the lack of a content-type definition. Without this being defined, he / most browsers assume that text / html is sent back, where the encoding is not really defined, especially since the .woff2 file will contain non-standard characters (ASCII!).

My solution (it may not work if your apache is significantly different, for example, does not allow addtype in .htaccess ) should have added the following to .htaccess in the corresponding root of the served site:

 AddType application/x-font-woff2 .woff2 

(found this resource )

Worked for me!

.htaccess

+18
source

All Articles