Which compression class libraries enable front-end javascript to decompress the compressed data returned by the server?

Source: Internet
Author: User
The scenario is that the page has an ajax request, and the json data returned by the server is large, generally about 10 MB. To save server traffic and bandwidth, the backend php needs to compress json data and transmit it to the front end. The front-end javascript will decompress the data before processing. The scenario is as follows: the page has an ajax request, and the json data returned by the server is large, usually about 10 MB. To save server traffic and bandwidth, the backend php needs to compress json data and transmit it to the front end. The front-end javascript will decompress the data before processing.
Currently, the following situations have been attempted:
1. Use base64, but the compression ratio is small, only more than 20%.
2. Using the gzdeflate and gzcompress functions supported by php, the corresponding unzipping library is not found on the javascript end. Some inflate. js on git cannot be used at all, and the browser crashes due to excessive loops.
3. Find an lzma compression and decompression Library Supported by javascript, which is good, but does not find related functions supported by php.
So here, I beg you to see if there is a compression method that enables both the front and back ends to use this method for compression and decompression. Thank you!

Reply content:

The scenario is that the page has an ajax request, and the json data returned by the server is large, generally about 10 MB. To save server traffic and bandwidth, the backend php needs to compress json data and transmit it to the front end. The front-end javascript will decompress the data before processing.
Currently, the following situations have been attempted:
1. Use base64, but the compression ratio is small, only more than 20%.
2. Using the gzdeflate and gzcompress functions supported by php, the corresponding unzipping library is not found on the javascript end. Some inflate. js on git cannot be used at all, and the browser crashes due to excessive loops.
3. Find an lzma compression and decompression Library Supported by javascript, which is good, but does not find related functions supported by php.
So here, I beg you to see if there is a compression method that enables both the front and back ends to use this method for compression and decompression. Thank you!

10 MB is too scary. We recommend that you load the list by page or scroll.

The server compresses Response into gzip. I estimate that 10 MB of files will only contain 4 MB.

The original purpose of JSON is to replace XML and simplify network interaction. Therefore, JSON itself is simplified. If your data is large, we recommend that you adjust the data structure, for example, replace the key and value format with arrays.

Although there are alternative solutions, JSON serialization and deserialization are Native. If you use a third party, You need to provide a decoding package. Imagine a 10 mb data structure, how long does it take to decode the client?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.