Node.js AdvancedLesson 96Free preview
Zlib Module
This lesson is part of Node.js · All levels
Summary
This lesson discusses the zlib modules for data compression and decompression in Node.js, supporting gzip, deflate, and brotli. You'll use both synchronous and stream methods to save bandwidth and storage. Compression is often used in HTTP (middleware compression) responses and file storage.
Key points
- The zlib module supports the following algorithms: gzip, deflate, brotli, and raw deflate.
- Methods are available: gzipSync/ gunzipSync (synchronous), as well as createGzip() based stream.
- For big data, use the stream to keep the memory stable.
- HTTP: Content-Encoding header: gzip tells the client that the body has been compressed.
- Always keep the compressed data in the same format when decompressing (gzip vs brotli).
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.