New ThinkPHP3.1 feature: page compression and output support

Source: Internet
Author: User
Most browsers now support page compression Output. by compressing the output, the page size can be reduced by 30%. Because version 3.0 does not have the built-in page compression output function, generally, you need to add it in the entry File: most browsers now support page compression Output. by compressing the output, the page size can be reduced by 30%. Because version 3.0 does not have the built-in page compression output function, therefore, you need to add the following in the entry file:
  1. Ob_start ('OB _ gzhandler ');
Copy the code, but because of the different server environments, sometimes this configuration conflicts with the zlib compression configuration in the php. ini file. The new version 3.1 has built-in page compression output function. you do not need to manually add the ob_gzhandler code, add OUTPUT_ENCODE configuration parameters, and support detection of zlib. output_compression.
By default, the framework compresses the page output and automatically detects zlib. output_compression configuration, if php. zlib in ini. when output_compression is enabled, the page is still compressed by page compression in the server environment.
The related code is just one line:
  1. If (! Ini_get ('zlib. output_compression') & C ('output _ encoding') ob_start ('OB _ gzhandler ');
If an error similar to the following occurs when copying code in some special environments:
  1. Output_handler "ob_gzhandler" conflicts with "zlib. output_compression"
The replication code is usually caused by conflicts when other compression methods are configured on your server. in this case, you can manually disable OUTPUT_ENCODE, that is:
  1. 'Output _ encode' => false

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.