cowboy_compress_h.asciidoc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. = cowboy_compress_h(3)
  2. == Name
  3. cowboy_compress_h - Compress stream handler
  4. == Description
  5. The module `cowboy_compress_h` compresses response bodies
  6. automatically when the client supports it. It will not
  7. try to compress responses that already have a content
  8. encoding.
  9. Normal responses will only be compressed when their
  10. size is lower than the configured threshold. Streamed
  11. responses are always compressed, including when the
  12. sendfile command is used. Because the file must be
  13. read in memory to be compressed, this module is *not*
  14. suitable for automatically compressing large files.
  15. == Options
  16. [source,erlang]
  17. ----
  18. opts() :: #{
  19. compress_buffering => boolean(),
  20. compress_threshold => non_neg_integer()
  21. }
  22. ----
  23. Configuration for the default stream handler.
  24. The default value is given next to the option name:
  25. compress_buffering (false)::
  26. Whether the output will be buffered. By default no
  27. buffering is done to provide maximum compatibility
  28. at the cost of a lower compression rate.
  29. compress_threshold (300)::
  30. How large the response body must be to be compressed
  31. when the response isn't streamed.
  32. == Events
  33. The compress stream handler does not produce any event.
  34. == Changelog
  35. * *2.6*: The options `compress_buffering` and
  36. `compress_threshold` were added.
  37. * *2.0*: Module introduced.
  38. == See also
  39. link:man:cowboy(7)[cowboy(7)],
  40. link:man:cowboy_stream(3)[cowboy_stream(3)],
  41. link:man:cowboy_stream_h(3)[cowboy_stream_h(3)]