分享

写回答

发帖

[提问] GD客服答复开启ob_gzhandler的问题

GoDaddy GoDaddy 1147 人阅读 | 2 人回复

发表于 2012-3-21 00:13:11 | 显示全部楼层 |阅读模式

还是和网上看到的一致,我用的是discuz,怎么才能加上这段PHP代码(不可能每个PHP都加),用htaccess还是?


以下是答复的邮件:

Dear Sir/Madam,

Thank you for contacting Online Support.  

Compression is a simple, effective way to save bandwidth and speed up your website in Linux Shared Hosting. By adding a piece of PHP code to the top of your Web pages, you can instruct the Web server to compress files for transit to your visitors' Web browser. This is especially useful for text-heavy Web pages that are over 100K in size.

To Optimize Your Site Using Compression

Add the following code to the very top of your Web pages above the DOCTYPE:

<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?>

Rename the file you want to compress with a .php extension instead of .html or .htm and upload the file to your site. The file will be compressed upon request and delivered to the visitors' browser.


Please let us know if we can assist you in any other way.

Sincerely,

Jesse P.
Online Support Team

回答|共 2 个

fusky

发表于 2012-3-21 00:26:00 | 显示全部楼层

貌似明白了,discuz可以通过修改配置文件来实现gzip,这个gzip压缩就是ob_gzhandler方式,难怪开启了zlib.output_compression后就必须关闭discuz的gzip,因为zlib.output_compression和ob_gzhandler不能同时使用!

先睡觉,明天来测下哪个压缩效果更大
回复 支持 反对

使用道具 举报

暮木娃娃

发表于 2012-3-21 08:37:26 | 显示全部楼层

fusky 发表于 2012-3-21 12:26 AM
貌似明白了,discuz可以通过修改配置文件来实现gzip,这个gzip压缩就是ob_gzhandler方式,难怪开启了zlib.o ...

等测试结果
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则