3, php.ini is
4, apache is added as follows:
Method 2, use zlib.output_compression in php.ini 1. Close mod_deflate.so in apache 2, php.ini:
2, php.ini is
Method 3, use PHP’s built-in function ob_gzhandler (must ensure that php_zlib.dll is installed and opened in the extension) 1. Close mod_deflate.so in apache 2. php.ini is
Instructions: In method three, if output_handler=ob_gzhandler is set in php.ini, then there is no need to add ob_start('ob_gzhandler'); in the program. Otherwise, it will be double compressed, which will actually report an error, and the general program will judge it. Set php.ini to be off by default and add it in the program, but if it is your own server, set ini to be on by default. It is recommended to use Type 1 or Type 2: (Type 1 is particularly recommended) At this time, ob_start() can customize the function, written like: ob_start("compress_html"); You can compress html format:
After this, not only the html format can be compressed (gzip can also be used). Complete configuration plan for method 1: 1. Open mod_deflate.so in apache 2. php.ini is
3. php.ini is;
4, apache adds as follows:
Use the following program in the php header that needs to be compressed in html format:
This turns on the gzip compression function of php, and Supports automatic compression and formatting of HTML when viewing source files with a browser, which is very useful. Turn on gzip compression, especially for small webmasters with insufficient funds, bandwidth is a waste of money. |