gzipyaws

How to enable gzip compression on YAWS?


How do I enable gzip compression on yaws?

I have this information:

With this patch, Yaws will add 'Accept-Encoding' in 'Vary' header if the
    support of gzip compression is enabled or if the response is compressed.
    The 'Vary' header can be set using 'yaws:outh_set_vary(Fields)' or by
    returning '{header, {vary, Fields}}' from scripts (where Fields is a list
    of header names).

The thing is that I do not know where to add yaws:outh_set_vary(Fields) or how to return {header, {vary, Fields}}.


Solution

  • The easiest thing to do is set deflate = true in the server block of your yaws.conf config file to enable deflate compression for that server. See the Yaws config documentation for more details about deflate, including an explanation of the optional <deflate> ... </deflate> block for customizing server compression settings.