Skip to content

Commit 2d3599a

Browse files
committed
docs: rewrite options documentation
1 parent b9efb48 commit 2d3599a

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,25 @@ app.use(compression({
3232

3333
#### Options
3434

35-
- `threshold` `<1kb>` - response is only compressed if the byte size is at or above this threshold.
36-
- `filter` - a filtering callback function. Uses [Compressible](https://github.com/expressjs/compressible) by default.
35+
`compression()` accepts these properties in the options object. In addition to
36+
those listed below, [zlib](http://nodejs.org/api/zlib.html) options may be
37+
passed in to the options object.
3738

38-
In addition to these, [zlib](http://nodejs.org/api/zlib.html) options may be passed in to the options object.
39+
##### filter
40+
41+
A function to decide if the response should be considered for compression.
42+
This function is called as `filter(req, res)` and is expected to return
43+
`true` to consider the response for compression, or `false` to not compress
44+
the response.
45+
46+
The default filter function uses the [compressible](https://www.npmjs.com/package/compressible)
47+
module to determine if `res.getHeader('Content-Type')` is compressible.
48+
49+
##### threshold
50+
51+
The byte threshold for the response body size before compression is considered
52+
for the response, defaults to `1kb`. This is a number of bytes, any string
53+
accepted by the [bytes](https://www.npmjs.com/package/bytes) module, or `false`.
3954

4055
### res.flush
4156

0 commit comments

Comments
 (0)