In curl-php, when does the compression start after enabling buffer compression ob_start ('ob _ gzhandler?

Source: Internet
Author: User
Tags stream api
After I start compressing ob_start (& #039; ob_gzhandler & #039;), I write the content of ob_get_contents to the file, but the content in the file is plain text, the string data is not compressed. Does it mean that this compression process is executed when the S end sends data to the c end? That is, to press the data... after enabling compression ob_start ('ob _ gzhandler'), I write the content of ob_get_contents to the file, but the content in the file is plain text, and the string data is not compressed.
Is this compression process executed when the S end sends data to the c end? That is, after the data is compressed, the http browser is sent to the client, while the local storage process does not enable compression?

If I want to compress the data locally, I can only perform fwrite ($ fp, gzcompress (ob_get_contents?

Reply content:

After enabling compression ob_start ('ob _ gzhandler'), I write the content of ob_get_contents to the file, but the content in the file is plain text, and the string data is not compressed.
Is this compression process executed when the S end sends data to the c end? That is, after the data is compressed, the http browser is sent to the client, while the local storage process does not enable compression?

If I want to compress the data locally, I can only perform fwrite ($ fp, gzcompress (ob_get_contents?

Yes,ob_start('ob_gzhandler')Is to compress the output cache of the page only, according to the compression method requested by the browser ('gzip ', 'deflate') Corresponding compression back.
The gzcompress compression method is ZLIB, And the gzencode is gzip. Local, you can only gzcompress (ob_get_contents ().

obIs the abbreviation of Output Buffer, which is used to manipulate the Output (CGI is the page)

To read and write local compressed files, we recommend that you usezlib://YOUR_FILE_PATHThis method is used to read and write local compressed files (documents). The stream api should reduce the overhead of function call and intermediate memory, and the code is clean, it is also easy to make the configuration decide whether to compress or not, and you can also implement it yourself if necessaryxxx://I vaguely remember that SAE was playing like this.

Related Article

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.