When does the compression ob_start (' Ob_gzhandler ') start in curl-php?

Source: Internet
Author: User
After I turn on the compression ob_start (' Ob_gzhandler '), the contents of the ob_get_contents are written into the file, but the contents of the file are plain text, and the string data is not compressed
Is this compression process performed when the S-side sends data to the C-end? That is, the browser that compresses the data and takes the HTTP to the client, while the local stored procedure does not enable compression?

If I want to compress the data locally, I can only fwrite ($fp, Gzcompress (Ob_get_contents ())).

Reply content:

After I turn on the compression ob_start (' Ob_gzhandler '), the contents of the ob_get_contents are written into the file, but the contents of the file are plain text, and the string data is not compressed
Is this compression process performed when the S-side sends data to the C-end? That is, the browser that compresses the data and takes the HTTP to the client, while the local stored procedure does not enable compression?

If I want to compress the data locally, I can only fwrite ($fp, Gzcompress (Ob_get_contents ())).

The right ob_start('ob_gzhandler') is to compress only the page's output cache, which is returned according to the compression method requested by the browser (' gzip ', ' deflate ').
The Gzcompress compression method is Zlib,gzencode is gzip. Local words, only gzcompress (Ob_get_contents ())

obis the abbreviation for output buffer, which is used to manipulate the outputs (in the case of CGI is the page)

If you want to read and write local compressed files, there are many, I recommend using zlib://YOUR_FILE_PATH this method to read and write local compressed files (documents), stream form of the API should be able to reduce the function call and intermediate memory overhead, code is clean, but also can easily be configured to determine whether compression or not, You can do it yourself if you need to xxx:// . Remember that SAE is playing like that.

  • 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.