uNetworking / uWebSockets.js

μWebSockets for Node.js back-ends :metal:
Apache License 2.0
7.62k stars 558 forks source link

Sending Pre-Compressed Buffers? #1076

Open ronag opened 5 days ago

ronag commented 5 days ago

Would it be possible to send pre-compressed data? i.e. if one caches messages one could cache the compressed version in order to avoid compressing during every send?

e.g.

Instead of:

cache.set(key, buf)
// ...
for (const socket of sockets) (  
  socket.send(cache.get(key)) // compressed by uws
}
cache.set(key, zlib.deflateSync(buf))
// ...
for (const socket of sockets) (
  socket.send(cache.get(key))
}

This would enable 2 things:

ronag commented 5 days ago

If this is possible to implement I would consider funding the work.