Koa Compressor is a middleware for Koa.js designed to simplify HTTP response compression by *always* applying gzip compression. Unlike more configurable alternatives like `koa-compress`, this package explicitly ignores the `Accept-Encoding` header, does not set a `Vary` header, and lacks the `this.compress` option for manual control. It sets the `Content-Length` header on compressed bodies. The package is currently at version 1.0.3, with its last publish approximately seven years ago, indicating it is no longer actively maintained. This makes it primarily compatible with older Koa 1.x applications which rely on generator-based middleware, and it lacks support for modern Koa 2.x+ async/await middleware patterns or contemporary compression algorithms like Brotli or Zstandard.
npm install koa-compressorVerified import paths — ran on the pinned version, not inferred.
Demonstrates a basic Koa 1.x application using `koa-compressor` middleware to unconditionally gzip compress all responses.
For Koa 2.x and later, use `koa-compress` (the actively maintained alternative) which supports async/await middleware and offers more configurable compression options, including Brotli and Zstandard. Do not attempt to use `koa-compressor` with modern Koa applications.
If flexible compression (e.g., Brotli, Deflate), client `Accept-Encoding` negotiation, or proper `Vary` header handling is required, use `koa-compress`. `koa-compressor` is suitable only for very specific use cases where unconditional gzip compression is desired and `Accept-Encoding` can be safely ignored (e.g., SPDY/HTTP/2 with specific client constraints).
Migrate to `koa-compress` for active maintenance, modern Koa compatibility, broader compression algorithm support, and ongoing security updates.
This package is not compatible with Koa 2.x+. Downgrade Koa to 1.x (not recommended for new projects) or, preferably, switch to `koa-compress` which is compatible with modern Koa versions and maintained.
Ensure the package is installed (`npm install koa-compressor`). If using Node.js without an ESM setup (which is likely for this older package), use `const compressor = require('koa-compressor');`. For ESM projects, this package is not suitable; use `koa-compress` instead.