为什么我的托管公司不支持 mod_deflate?
我刚刚用 YSlow 做了一些测试,它告诉我:
使用 gzip 压缩组件的 F 级:有 10 个纯文本 应压缩发送的组件
我知道 Apache 1.3 使用 mod_gzip
而 Apache 2.x 使用 mod_deflate
,因此解决此问题的最简单解决方案是使用 mod_deflate
在 Apache 2 服务器上。
不过,我咨询了两家共享托管公司和一家本地公司,他们都告诉我他们不支持 mod_deflate
。
我知道一些较旧的浏览器在接受 gzipped / deflated 内容时遇到困难,我并不建议默认启用它,但是使 mod_deflate
可用是否有任何负面影响?这只是服务器处理器上的额外负载吗?
另外,还有其他选择吗?我发现,如果您使用的是像 Wordpress 这样的 CMS,您可能会安装一个缓存插件,该插件将提供最初通过 PHP 生成的页面的 gzip 缓存版本。
I was just doing some testing with YSlow and it's telling me:
Grade F on Compress components with gzip: There are 10 plain text
components that should be sent compressed
I know that Apache 1.3 uses mod_gzip
while Apache 2.x uses mod_deflate
, and so the easiest solution to remedy this is to use mod_deflate
on an Apache 2 server.
However, I've checked with two shared hosting companies and one local company and they've all told me that they don't support mod_deflate
.
I know that some older browsers have trouble accepting gzipped / deflated content, and I'm not suggesting it be enabled by default, but are there any negatives for making mod_deflate
available? Is it just extra load on the server's processors?
Also, are there any alternatives? I saw that if you are using a CMS like Wordpress you could potentially install a caching plugin which would serve out gzipped cached versions of the pages initially generated via PHP.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
压缩需要CPU时间。也许托管公司认为他们更关心 CPU 而不是网络流量。也许他们会提供更昂贵的套餐。也许他们只是没有添加它。只有您的托管公司才会知道。
使用 PHP 时,您可以检查您的 PHP 设置是否启用了 zlib 支持。如果是这种情况,您可以在代码中使用 ob_start("ob_gzhandler"); 来启用输出缓冲区,该缓冲区将压缩您的数据或在 php 配置中设置
zlib.output_compression
例如,在.htaccess
文件中使用php_flag zlib.outout_compression on
。http://php.net/ob_gzhandler
http://php.net/zlib.output-compression
Compression takes CPU time. Maybe the hosting company decided they care more about CPU than network traffic. Maybe they offer it with a more expensive package. MAybe they simply didn't add it. Only your hosting company would know.
When using PHP you can check whether your PHP setup has zlib support enabled. If that is the case you can use
ob_start("ob_gzhandler");
in code to enable an output buffer which will compress your data or setzlib.output_compression
in your php configuration for instance by usingphp_flag zlib.outout_compression on
in your.htaccess
file.http://php.net/ob_gzhandler
http://php.net/zlib.output-compression