When a server delivers some messages to a client using an HTTP protocol, data compression may be performed to save bandwidth. It can make the data size becomes smaller with the cost of CPU processes. Node.js has a built-in library to handle compression, as I mentioned in another post . For instance, we will see an HTTP server built on Fastify that utilizes the zlib module to compress data returned by the server module in the following code. import Fastify, { FastifyInstance } from 'fastify'; import { join } from 'path'; import { createReadStream } from 'fs'; import zlib from 'zlib'; const PORT = 3000; const fastify: FastifyInstance = Fastify({ logger: true }); fastify.get('/', (request, reply) => { // get request header const acceptEncoding = request.headers['accept-encoding'] || ''; const rawStream = createReadStream(join(process.cwd(), 'text.txt')); reply.header('Content-Type', 'text/plain