comprimir y descomprimir texto de html al servidor y viceversa

We are going to write a feature on my system that will require a very massive user http post and http response, probably millions of requests/response with just some bytes each ( sending and getting with ajax and json )

but that's not enough I need to find a way to compress the data with java script and decompress on the server side ( .net or java servlets ) and also compress on the server and decompress with javascript.

It seems silly save such bytes, but I want to be prepared for the worst.

Any directions? just post what you think, let's share our thoughts



preguntado el 10 de marzo de 12 a las 02:03

What is the use-case for this scenario? -

5 Respuestas

En Java, puede utilizar el package which should provide you with compress-/decompress methods.

For JavaScript I found este tutorial. Or you could implement your own method by replacing all unicode characters of the byte-stream like this:

Tu mensaje:
Unicode Bytes:
0x41 0x00 0x41 0x00 0x42 0x00 0x43 0x00 0x43 0x00 0x43 0x00
compressed by leaving out the 0x00 :
0x41 0x41 0x42 0x43 0x43 0x43
even more by leaving out doubles:
2 0x41 1 0x42 3 0x43

Even though it doesn't look very impressive right now, there might be one or two requests that could profit from this compression. Although it is really important for the algorithm to be very effective and sufficient. Since you are talking about 'millions' of requests. One big request could profit from this compression, but many small requests could be very inefficient.

Sorry I can't provide you with a complete solution, but maybe this brings you a little closer.

respondido 10 mar '12, 03:03

Is a server-level implementation of zlib compression not good enough for your use case? That'd be the most simple and reliable way to get compression working. All the most common web servers and browsers support zlib compression out of the box.

respondido 10 mar '12, 02:03

You can use HTTP Compression suppoerted by major web servers, app servers and browsers. While you do that, note that IE has historically been very buggy in that area, so make sure that it works in multiple versions of IE. For apache, you can use mod_deflate. Jetty & Tomcat have their own versions of a GZIP filter. Compressing/Decompressing in Javascript will be cumbersome. I am not aware of any libraries available in JS that can help you.

respondido 10 mar '12, 02:03

Performance questions require you to try and measure to get any reasonable answer.

In your case I would carefully look at raw message and see where bytes are - I bet that for tiny data packets most of the bytes would be in headers, so compression of content will give you no benefit. It is your system - look at your requests and see where you can get decrease size of packets.

Note that often you need to send user's authentication with the request - as result your request will have fixed size, usually non-compressible chunk of data in it.

respondido 10 mar '12, 02:03

respondido 10 mar '12, 02:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.