
Security News
Insecure Agents Podcast: Certified Patches, Supply Chain Security, and AI Agents
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.
koa-compress
Advanced tools

Compress middleware for Koa
var compress = require('koa-compress')
var koa = require('koa')
var app = koa()
app.use(compress({
filter: function (content_type) {
return /text/i.test(content_type)
},
threshold: 2048,
flush: require('zlib').Z_SYNC_FLUSH
}))
The options are passed to zlib: http://nodejs.org/api/zlib.html#zlib_options
An optional function that checks the response content type to decide whether to compress. By default, it uses compressible.
Minimum response size in bytes to compress.
Default 1024 bytes or 1kb.
You can always enable compression by setting this.compress = true.
You can always disable compression by setting this.compress = false.
This bypasses the filter check.
app.use(function (next) {
return function *() {
this.compress = true
this.body = fs.createReadStream(file)
}
})
The 'compression' package is a middleware for Express.js that provides HTTP compression. It supports gzip and deflate algorithms. Compared to koa-compress, it is designed specifically for Express.js and does not support Brotli compression out of the box.
The 'shrink-ray-current' package is a middleware for Node.js that provides HTTP compression using gzip, deflate, and Brotli algorithms. It is similar to koa-compress in terms of supported algorithms but can be used with various frameworks, not just Koa.
FAQs
Compress middleware for koa
The npm package koa-compress receives a total of 317,243 weekly downloads. As such, koa-compress popularity was classified as popular.
We found that koa-compress demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 11 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.

Security News
The planned feature introduces a review step before releases go live, following the Shai-Hulud attacks and a rocky migration off classic tokens that disrupted maintainer workflows.