pierrec / node-lz4

LZ4 fast compression algorithm for NodeJS
MIT License
438 stars 98 forks source link

Sending browser compressed data via AJAX request (jquery) #18

Closed iccube-real closed 10 years ago

iccube-real commented 10 years ago

I'm using LZ4 in the browser to compress lengthy AJAX request parameter. I'm wondering how to encode the content of the compressed Buffer to send as a parameter of the AJAX request? Do you have any example and/or pointer ?

Thanks and congrats. for your work.

pierrec commented 10 years ago

Hello there,

Sorry for the late reply, I was on holidays without any inet access :).

Encoding the compressed data will make you lose the compression benefits in most cases - unless your data is highly compressible. There is sort of an example on how to do that in examples/compress.html, where you can input some data and it will show the base64 encoded result.

Let me know if this is clear enough.

iccube-real commented 10 years ago

Thanks. Actually once my Buffer has been compressed I'm using Buffer.toString( 'base64' ) which adds around 30% to the compressed data but still my data is 3 to 5 times compressed. The kind of data I'm compressing usually contains a lot of identical blocks which I believe is nice for LZ4.