响应标头中的网络X内容编码而不是内容编码 [英] 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)点击设置,然后点击高级设置
2) Click Setup then Advance Setup
3)搜索 HTTP
4)禁用 HTTP扫描器
这篇关于响应标头中的网络X内容编码而不是内容编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!