目前大多数浏览器都已经支持页面的压缩输出,通过压缩输出,页面大小可以减少30%,但是由于3.0及以前的版本都没有内置页面压缩输出功能,所以一般来说,开发人员需要自己在入口文件中添加:
ob_start('ob_gzhandler');
但是由于服务器环境的不同,有时候这个配置会和php.ini文件中的zlib压缩配置冲突。而ThinkPHP3.1版则内置了页面压缩输出的功能,不再需要再手动添加ob_gzhandler代码,增加OUTPUT_ENCODE配置参数,并支持检测zlib.output_compression。
框架默认会进行页面压缩输出,并且会自动检测zlib.output_compression配置,如果php.ini里面zlib.output_compression是开启状态,则仍然以服务器环境的页面压缩方式进行页面压缩。
相关代码只有一行:
if(!ini_get('zlib.output_compression') && C('OUTPUT_ENCODE')) ob_start('ob_gzhandler');
在个别特殊的环境下面,如果出现类似下面的错误提示:
output_handler "ob_gzhandler" conflicts with "zlib.output_compression"
一般是由于你的服务器配置了其他的压缩方式导致冲突,这个时候你可以手动关闭OUTPUT_ENCODE,即:
'OUTPUT_ENCODE'=>false
就可以解决问题。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version
Visual web development tools
