WOFF2如何在HTTPheader中指定页面使用的字符集?

How to specify the character set used by the page in the HTTP header for WOFF2?

我在我的 Drupal 8 网站上托管了 google 字体。

当我使用不同的工具扫描我的网站时,出现以下错误消息:

Specify a character set in your response HTTP headers No character sets are specified in the HTTP headers of the following resources. Specifying a character set speeds up the display of pages in the browser.

https://www.domaine.com/themes/custom/bootstrap_subtheme_front_office/fonts/source-sans-pro-v11-latin-700.woff2 https://www.domaine.com/themes/custom/bootstrap_subtheme_front_office/fonts/source-sans-pro-v11-latin-regular.woff2 https://www.domaine.com/themes/custom/bootstrap_subtheme_front_office/fonts/source-sans-pro-v11-latin-regular.woff2

Specifying the character set used by the page in the HTTP Content-Type header allows the browser to start its analysis right away.

我该如何解决?

WOFF有自己的binary file format,所以真的不需要指定字符集

Specifying a character set speeds up the display of pages in the browser.

Specifying the character set used by the page in the HTTP Content-Type header allows the browser to start its analysis right away.

这用于 html 页面:大多数页面在 html 代码中使用类似于 <meta charset="utf-8"> 的内容。问题是浏览器在到达并解析 <meta> 标记之前不知道字符集。如果该字符集与默认设置不同,浏览器必须重新解析页面。

如果在 HTTP headers 中指定了字符集,则改为:

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

浏览器在开始解析页面之前就知道字符集。