[转]PHP ob_start() and ob_start('ob_gzhandler')
来源:互联网 发布:魔兽数据库 编辑:程序博客网 时间:2024/05/21 19:33
question:
What is the difference between using ob_start()
and ob_start('ob_gzhandler')
?
How does it affect the page speed ?
answer:
This doesn't affect page speed in the sense you'd might think.
the ob_gzhandler is a callback function which takes the contents from your output buffer and compresses the data before outputting it.
This reduces the size of the content being sent to the browser which might speed up the content transfer to the client. But it doesn't speed up your application/website.
PHP生成网页后传送给浏览器显示,生成的网页如果不经过处理,HTML将作原样输出。没经过压缩的网页容量有多大呢?我们来做个实验。我们用ZendFramework制作了一个有用户列表,并以表格输出其中的50行数据。输出前未作压缩的页面大小,如下:
然后,我们在这个基础上在引导文件index.php加上
[php]ob_start('gz_handler');[/php]
输出后的页面大小,压缩率是相当可观的。如下:
根据压缩原理我们知道,当文档中存在大量相同代码时,压缩率相对较高。
我们在写html代码时,有大量的缩进、空格、代码相同的表格数据。所以HTML的压缩率一般都比较高。
经过压缩后的代码传到浏览器后都能被现代流行的浏览器正确解析,我们查看源代码时依旧能看到整齐的代码。
只是在输出到浏览器的网络传输上,原来20K的内容被压缩至2K传送,大大提高了网页的响应速度。
压缩PHP输出代码的好处显而易见。
0 0
- [转]PHP ob_start() and ob_start('ob_gzhandler')
- PHP ob_start()与ob_gzhandler()
- PHP ob_start()与ob_gzhandler()
- php基于ob_start(ob_gzhandler)实现网页压缩功能的方法
- ob_start()
- ob_start()
- ob_start
- PHP Warning: ob_start() : output handler 'ob_gzhandler conflicts with 'zlib output compression'
- 71 PHP ob_start() 函数介绍(转)
- PHP中的ob_start()
- PHP的ob_start()相关
- 分析PHP的ob_start()
- PHP的ob_start()用法
- PHP的ob_start();用法
- PHP的ob_start();用法
- PHP ob_start() 函数介绍
- PHP的ob_start()
- PHP的ob_start()
- SVN历史版本删除 瘦身svn库
- MySQL-index
- 编写一个C程序,用于打印九九乘法表
- [POJ2104]K-th Number
- 大型网站图片服务器架构的演进
- [转]PHP ob_start() and ob_start('ob_gzhandler')
- isSubstring子串判断笔试题
- 一个社交App需实现的功能
- 随机字符串
- eclipse安装svn插件报eclipse subversion native library not available
- 关于classpath
- [POJ3264]Balanced Lineup
- [LeetCode]Power of Two
- 车载软件未来趋势