Browser prompts Err_content_decoding_failed,gzip compressed data cannot be decompressed

Source: Internet
Author: User

Recently on the page has a Display data table function, data from backstage to the foreground JS form plug-in. Data format is JSON

Due to the large amount of data, it is thought that gzip compression will be passed to the foreground. Before compression, the amount of data in a table is more than 3M, compressed with gzip about 200K.

The business process is to check whether there are static files in the cache, and if not, read them from the database and save them as files. In this process, I used gzip to compress first and then save. Then read the file directly the next time you read it.

The problem is that the browser does not decode the static file correctly after reading it, and err_conten_decoding_failed it. I searched the internet for a reason, there is said to be a document in the BOM header, will lead to decoding failure, after checking the generated file PHP no BOM header. Period, the suspicion is the problem of file encoding, so with editplus try to open, just open the hint to choose the encoding method, so chose UTF8, the result or not.

When I put the Gzencode location in the cache file read and then do the compression, found that the browser can decode normally. It is inferred that the problem may be caused by Gzencode compression when the data is saved as a file.

Open the static file with sublime, found that the encoding location shows "hexadecimal" (16 binary), and then try to use UTF8 encoding and then open the page, reported decoding error.

But now the data is the demand changes after the data, the volume is very small, itself is not compressed in the case of only about 100K. will be related to the length of the data. Then we go back to the branch where the requirements were not changed. After the test, it is shown that the encoding of the static file can be displayed as long as it is not changed.

The reason for decoding errors at the beginning is that I have been opening a static file several times before I have printed it on my browser, and have modified the encoding method.

Therefore, the files generated with Gzip must be encoded as 16 binary (hexadecimal) and not modified into other encoding formats.

Browser prompts Err_content_decoding_failed,gzip compressed data cannot be decompressed

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.