Php compresses the ob_gzhandler function in three ways. This article introduces three methods to compress the ob_gzhandler function in php. if you need to know the usage of the ob_gzhandler function, you can refer to this document. There are three methods to use the ob_gzhandler function in this article to introduce php to compress the ob_gzhandler function. if you need to know the usage of the ob_gzhandler function, you can refer to it.
There are three ways to use the ob_gzhandler function to compress php:
1. set output_handler = ob_gzhandler in php. ini.
2. add php_value output_handler ob_gzhandler to. htaccess.
3. add ob_start ('OB _ gzhandler') to the PHP file header ');
The first method is not feasible. The second method is good. once and for all, the effects of the first and second methods are the same, that is, compression of all php suffix files. Here I will mainly introduce the third method,
The CSS compression method is used as an example to compress style.css under the template.
1. copy style.cssin the Template directory and name it style.css. php.
Add this sentence to the top of style.css. php:
Add
2. modify the css connection in header. php as follows
Original:
Modified:
Now your CSS can be compressed by gzip.
JS can also use the same method, but the header added to xx. js. php should be like this:
(Remove when copying? Space before php)
Take a closer look at JS in the K2 topic, that is, add the ob_gzhandler function to the top after modifying the suffix to php.
The ob_gzhandler function can be used in three ways. if you need to know the usage of the ob_gzhandler function, please refer to it. There are three methods to use the ob_gzhandler function...