html - PageSpeed 工具的奇怪修复

标签 html optimization character-encoding character meta-tags

当我在 PageSpeed Tools(一种由 Google 优化网页的工具)中测试我的网页时,我遇到了这些问题:

问题#1:

Avoid a character set in the meta tag

The following resources have a character set specified in a meta tag.
Specifying a character set in a meta tag disables the lookahead downloader in IE8.
To improve resource download parallelization, move the character set to the HTTP Content-Type response header.

问题#2:

Specify a character set

Specifying a character set early for your HTML documents allows the browser to Begin executing scripts IMMEDIATELY.

Suggestions for this page

The following resources have not set the character set in HTTP headers.
If you specify a character set in there, speeds up the rendering in the browser.

但我不明白为什么会出现这些问题,因为我在头部指定了这样的字符集:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />

问题:有人可以帮我解决这些问题吗?

最佳答案

它告诉您:将字符集移至 HTTP Content-Type 响应 header 。看看这个:

Wikipedia - List of HTTP header fields

基本上,客户端从服务器返回的实际 HTTP 响应应该设置 Content-Type 字段。如果你不能改变这个,那么就在 <meta> 中设置它。照原样标记。

编辑:

如果可以,请修改服务器上的 .htaccess 文件以包括:

AddType 'text/html; charset=iso-8859-15' html

这将导致所有提供的 HTML 文件都包含适当的响应 header 。

关于html - PageSpeed 工具的奇怪修复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11157619/

相关文章:

html - 使用内联 block 与内联,两者似乎都不符合我的预期

javascript - Javascript中有重复声明优化吗?

sql - 有没有比子查询更有效的方法来将 group by 的结果与表连接起来?

php - 循环遍历 MySQL 数据库,使用 UTF-8 版本更改撇号

c++ - 如何使用 C++ 将 ucs4 转换为 ucs2 并将 ucs2 转换为 ucs4?

Javascript:一个函数可以检查同一组中的各个复选框,并单独存储答案

javascript - contentEditable attr 设置为 true 会使内容中的链接不可点击

javascript - 如何确保每个用户的注册表单都是唯一的,而不是相同的用户名、电子邮件或地址等?

c# - 如何使用 for 循环而不是 foreach 循环?

python - 如何使用Python源文件的 'coding' header 正确读取其内容?