nchan_deflate_message_for_websocket

The nchan_deflate_message_for_websocket directive enables message compression for WebSocket connections using the Nchan module.

Syntaxnchan_deflate_message_for_websocket on | off;
Defaultoff
Contextserver, location
Arguments1

Description

The nchan_deflate_message_for_websocket directive is part of the Nchan module for NGINX, which provides a scalable pub/sub server functionality. This directive specifically configures the WebSocket connections to compress messages before sending them to subscribers. By enabling this compression, the amount of data transferred over the network can be significantly reduced, which is especially beneficial for large messages and limited bandwidth environments.

To use this directive, an argument indicating whether to enable or disable compression must be provided. When set to 'on', Nchan will apply the DEFLATE compression algorithm to the messages sent through WebSocket channels, optimizing performance by minimizing the payload size. Conversely, setting the directive to 'off' will disable this compression feature, causing messages to be sent in their original uncompressed format. This can also be essential when dealing with specific client limitations or requirements that may prefer uncompressed data.

The directive can be placed in the server or location context, allowing for flexible configuration based on different routing scenarios within the NGINX server. It is crucial to note that compression may introduce some latency due to the processing overhead, and careful consideration should be given to message sizes and network conditions when deciding to enable this feature.

Config Example

location /nchan {
    nchan_deflate_message_for_websocket on;
    nchan_pubsub;
}

Ensure the WebSocket clients support DEFLATE compressed messages; otherwise, they may fail to connect or process messages correctly.

Be cautious of the additional CPU overhead introduced by message compression, especially under high load situations.

← Back to all directives