响应标头中的 X-Content-Encoding-Over-Network 但不是 Content-Encoding [英] X-Content-Encoding-Over-Network in Response Header but not Content-Encoding
问题描述
我正在尝试使用带有 Nginx 和 NodeJS 服务器的 Gzip 压缩使用 Next.js 编写的代码.
I'm trying to compress the code written with Next.js using Gzip deliver with Nginx and NodeJS server.
当我使用 curl -H "Content-Encoding: gzip"
进行验证时,配置似乎工作正常.
但是使用真正的浏览器(Chrome、Firefox)我在响应标头中找不到 Content-Encoding: gzip
属性.
而是出现了 X-Content-Encoding-Over-Network: gzip
.
It seems the config is working when I use curl -H "Content-Encoding: gzip"
to verify.
But come to real browser (Chrome, Firefox) I cannot find the Content-Encoding: gzip
property in Response Headers.
Instead, X-Content-Encoding-Over-Network: gzip
is appeared.
我使用 Google Lighthouse 测试该网站,它责怪我启用文本文件压缩.
I use Google Lighthouse to test though the site, it blames me to enable compression on text file.
其实X-Content-Encoding-Over-Network
是什么意思?
我怎样才能让 gzip 使用它?
Actually, what does X-Content-Encoding-Over-Network
mean?
How can I get the gzip work with this?
Nginx 设置:
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.0;
gzip_types
text/css
text/plain
text/javascript
application/javascript
application/json
application/x-javascript
application/xml
application/xml+rss
application/xhtml+xml
application/x-font-ttf
application/x-font-opentype
application/vnd.ms-fontobject
image/svg+xml
image/x-icon
application/rss+xml
application/atom_xml;
Next.js 设置
// next.config.js
module.exports = {
compress: true
};
推荐答案
你的配置刚刚好.有时,问题是由防病毒引起的,就像评论中提到的那样.尝试禁用防病毒软件,或者在您的防病毒程序中搜索 HTTP 扫描选项.
Your configuration is just good. Sometimes, the problem is caused by Antivirus just like mentioned in comment. Try disabling the antivirus or instead search for HTTP Scanning option in your antivirus program.
NOD Internet Security 做到了这一点.您可以通过以下方式禁用此选项,
NOD Internet Security does this. You can disable this option by following,
1) 打开NOD Internet Security
2) 点击设置,然后点击高级设置
3) 搜索 HTTP
4) 禁用 HTTP 扫描程序
这篇关于响应标头中的 X-Content-Encoding-Over-Network 但不是 Content-Encoding的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!