Do not compress event-stream
jinxmcg opened this issue · comments
Hi,
With this module enabled it also compresses text/event-stream Content-type, whch is the default for SSE events (fastify-sse module for example).
The SSE output gets compressed and the browser does not trigger anymore SSE events onmessage
I suggest the regexp
const compressibleTypes = /^text\/|\+json$|\+text$|\+xml$/
should be changed to not allow text/event-stream but allow text/
this happens even if the browser specifies that it accepts "accept-encoding:gzip, deflate, br"
(think is a browser issue, but...chrome and firefox are pretty established to ignore it)
Update: in the end I added x-no-compression header to the request on the server side, but still I think it should be avoided by default by the module
Definitely, would you like to send a PR?
Having in mind that this would be a issue related to SSE events would not be better instead for me to send a PR to the fastify-sse module to add by default x-no-compression header to requests for which fastify-compress handles it well?
Which approach do you think would be better?
Nice idea! I think send a pr to fastify-sse
is the best option, in this way our regex will be more lightweight :)
Continued in
lolo32/fastify-sse#2