- MERN Quick Start Guide
- Eddy Wilson Iriarte Koroliova
- 170字
- 2021-06-25 21:30:18
How it works...
The output of the Terminal will show the content encoding mechanism that the client (for example web browser) supports. It may look something like this:
[ 'gzip', 'deflate', 'sdch', 'br', 'identity' ]
The content encoding mechanism sent by the client is used by compression internally to know if compression is supported. If compression is not supported, then the response body is not compressed.
If opening Chrome Dev Tools or similar and analyzing the request made, the Content-Encoding header that was sent by the server indicates the kind of content encoding mechanism used by compression.
Chrome Dev Tools | Network Tab displaying Response Headers
The compression library sets the Content-Encoding header to the encoding mechanism used for compressing the response body.
The threshold option is set by default to 1 KB which means that if the response size is below the number of bytes specified, then it is not compressed. Set it to 0 or false to compress the response even when the size is below 1 KB