njs: output compression?

Gunter Grodotzki gunter at grodotzki.com
Thu Apr 29 06:22:23 UTC 2021

Hi :)

So my njs script is outputting html but I would like that output to be compressed for the client (if the client supports).

So kind hoping that gzip or brotli module would be chained after njs, but seems that is only the case if you do an internalredirect.


> On 29 Apr 2021, at 04:23, Sergey A. Osokin <osa at freebsd.org.ru> wrote:
> Hi Gunter,
>> On Thu, Apr 29, 2021 at 03:34:39AM +0200, Gunter Grodotzki wrote:
>> Hi all,
>> Is there a simple way that I am missing to enable output compression for njs
>> scripts?
> I don't think it's good practice to use the njs module for
> a compression or any other heavy-math calculations.
>> It seems to be working for r.internalRedirect(‘/foo.html’)
>> But not for:
>> r.headersOut['Content-Type'] = 'text/html; charset=UTF-8'
>> r.return(200, someHtml)
> Could you share more light about goals you're doing to archive
> in this case.
> -- 
> Sergey Osokin
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel

More information about the nginx-devel mailing list