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?