Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

X-Content-Encoding-Over-Network in Response Header but not Content-Encoding

Tags:

I'm trying to compress the code written with Next.js using Gzip deliver with Nginx and NodeJS server.

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.

I use Google Lighthouse to test though the site, it blames me to enable compression on text file.

Actually, what does X-Content-Encoding-Over-Network mean?
How can I get the gzip work with this?

Nginx setting:

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 Setting

// next.config.js
module.exports = {
  compress: true
};
like image 867
Lillian Kwok Avatar asked Oct 15 '19 09:10

Lillian Kwok


People also ask

What is content encoding in header?

The Content-Encoding representation header lists any encodings that have been applied to the representation (message payload), and in what order. This lets the recipient know how to decode the representation in order to obtain the original payload format.

Where do I put content encoding gzip?

The “content-encoding: gzip” HTTP Response Header You can open up Chrome DevTools or Firefox Developer Tools and look for this response header under the Network section.

What is encoding in response?

The response encoding is the character encoding of the textual response generated by a web component. The response encoding must be set appropriately so that the characters are rendered correctly for a given locale.

Is accept-encoding a HTTP header?

The Accept-Encoding request HTTP header indicates the content encoding (usually a compression algorithm) that the client can understand. The server uses content negotiation to select one of the proposals and informs the client of that choice with the Content-Encoding response header.


1 Answers

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 does this. You can disable this option by following,

1) Open NOD Internet Security

2) Click Setup then Advance Setup

3) Search for HTTP

4) Disable HTTP Scanner

like image 108
Airy Avatar answered Sep 16 '22 11:09

Airy