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
};
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With