在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:koajs/compress开源软件地址:https://github.com/koajs/compress开源编程语言:JavaScript 100.0%开源软件介绍:Koa CompressCompress middleware for Koa Exampleconst compress = require('koa-compress')
const Koa = require('koa')
const app = new Koa()
app.use(compress({
filter (content_type) {
return /text/i.test(content_type)
},
threshold: 2048,
gzip: {
flush: require('zlib').constants.Z_SYNC_FLUSH
},
deflate: {
flush: require('zlib').constants.Z_SYNC_FLUSH,
},
br: false // disable brotli
})) Maintainers
Optionsfilter<Function>function (mimeType: string): Boolean {
} An optional function that checks the response content type to decide whether to compress. By default, it uses compressible. options.threshold<String|Number>Minimum response size in bytes to compress.
Default options[encoding]<Object>The current encodings are, in order of preference: options.brBrotli compression is supported in node v11.7.0+, which includes it natively. As of v5.1.0, the default quality level is 4 for performance reasons. options.defaultEncoding<String>An optional string, which specifies what encoders to use for requests without
Accept-Encoding.
Default The standard dictates to treat such requests as Manually turning compression on and offYou can always enable compression by setting app.use((ctx, next) => {
ctx.compress = true
ctx.body = fs.createReadStream(file)
}) |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论