blob: 048a4ac9c65e377f4b12b41f6c651dd84e3c7299 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
= cowboy_compress_h(3)
== Name
cowboy_compress_h - Compress stream handler
== Description
The module `cowboy_compress_h` compresses response bodies
automatically when the client supports it. It will not
try to compress responses that already have a content
encoding or that have an etag header defined.
Normal responses will only be compressed when their
size is lower than the configured threshold. Streamed
responses are always compressed, including when the
sendfile command is used. Because the file must be
read in memory to be compressed, this module is *not*
suitable for automatically compressing large files.
== Options
[source,erlang]
----
opts() :: #{
compress_buffering => boolean(),
compress_threshold => non_neg_integer()
}
----
Configuration for the compress stream handler.
The default value is given next to the option name:
compress_buffering (false)::
Whether the output will be buffered. By default no
buffering is done to provide maximum compatibility
at the cost of a lower compression rate.
+
This option can be updated at any time using the
`set_options` stream handler command.
compress_threshold (300)::
How large the response body must be to be compressed
when the response isn't streamed.
+
This option can be updated at any time using the
`set_options` stream handler command.
== Events
The compress stream handler does not produce any event.
== Changelog
* *2.11*: Compression is now disabled when the etag
header is in the response headers.
* *2.6*: The options `compress_buffering` and
`compress_threshold` were added.
* *2.0*: Module introduced.
== See also
link:man:cowboy(7)[cowboy(7)],
link:man:cowboy_stream(3)[cowboy_stream(3)],
link:man:cowboy_decompress_h(3)[cowboy_decompress_h(3)],
link:man:cowboy_metrics_h(3)[cowboy_metrics_h(3)],
link:man:cowboy_stream_h(3)[cowboy_stream_h(3)],
link:man:cowboy_tracer_h(3)[cowboy_tracer_h(3)]
|