Json compression sent using jquery

I am sending a json string to my server, but I wonder if there is a way to publish this string compressed with gzip? the content length is 24kb, which is the same size as if I selected the published JSON and pasted it into a text file, so it is clearly not compressed.

+6
source share
2 answers

You can use some JS library for data compression, for example, this implementation of Huffman compression . However, the added compression slowness can very well compensate for the time you save in download speed. You should try this and make this decision for yourself, but overall it sounds like it’s not worth it. Moreover, this means loading more JS code, which creates a slower page loading time.

Unfortunately, browsers do not provide an API for any compression algorithms. Thus, you cannot use the fast inline implementation.

+1
source

In fact, when the server sends a response compressed in gzip, it, since the client of the request tells the server using http encoding, what compressed formats it can accept. This is why the server compresses and sends the response because it knows through the request that the client can handle gzip, etc.

Now clients believe that the server can handle a compressed request, I'm not sure about that.

Ok i found this

Can I compress HTTP requests using gzip?

-1
source

Source: https://habr.com/ru/post/890362/


All Articles