简体   繁体   English

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

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

I hosted the google font on my Drupal 8 site. 我在我的Drupal 8网站上托管了Google字体。

When I scan my site with different tool, I have this error message : 当我使用其他工具扫描网站时,出现以下错误消息:

Specify a character set in your response HTTP headers No character sets are specified in the HTTP headers of the following resources. 在响应HTTP标头中指定字符集在以下资源的HTTP标头中未指定字符集。 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 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. 通过在HTTP Content-Type标头中指定页面使用的字符集,浏览器可以立即开始其分析。

How can I fix that ? 我该如何解决?

WOFF has its own binary file format , so there is really no need to specify a character set. WOFF有其自己的二进制文件格式 ,因此实际上不需要指定字符集。

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. 通过在HTTP Content-Type标头中指定页面使用的字符集,浏览器可以立即开始其分析。

This is used for html pages: most pages use something like <meta charset="utf-8"> in the html code. 这用于html页面:大多数页面在html代码中使用类似<meta charset="utf-8">的东西。 The problem is that the browser doesn't know the character set until it reaches and parses that <meta> tag. 问题在于浏览器直到到达并解析该<meta>标签才知道字符集。 If that character set is different from the default setting, the browser has to reparse the page. 如果该字符集与默认设置不同,则浏览器必须重新分析页面。

If the character set is specified in the HTTP headers instead: 如果在HTTP标头中指定了字符集,则:

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

the browser knows the character set before it starts parsing the page. 浏览器在开始解析页面之前就知道了字符集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM