如何启用gzip? [英] How to enable gzip?
问题描述
我已经找到了如何启用gzip几个教程,BTU似乎没有任何为我工作,所以我的问题是如何启用gzip压缩。我是一个共享Dreamhost的服务器上,这是运行PHP版本5.2和Apache,从PHP的信息我已经找到这一行,也许这可以帮助?
I have found a couple of tutorials on how to enable gzip, btu nothing seems to be working for me, so my question is how do i enable gzip. I am on a shared Dreamhost server, It is running PHP version 5.2, and Apache, from the php info i have found this line, maybe this could help?
zlib
ZLib Support enabled
Stream Wrapper support compress.zlib://
Stream Filter support zlib.inflate, zlib.deflate
Compiled Version 1.2.3.3
Linked Version 1.2.3.3
Directive Local Value Master Value
zlib.output_compression Off Off
zlib.output_compression_level -1 -1
zlib.output_handler no value no value
我还发现这行
I have also found this line
_SERVER["HTTP_ACCEPT_ENCODING"] gzip, deflate
我不知道这有什么关系呢。但是,这是我的第一个问题,第二,我有保管箱,托管javscript文件,我想知道是否有可能有一个文件gzip压缩,它没有被转移的COM pressed,所以疗法没有办法这样做?
I don't know if that has anything to do with it. But that is my first question, secondly, i have dropbox, hosting a javscript file, and I am wondering is it possible to have that file gzipped, It is not being transfered compressed, so is ther any way to do so?
推荐答案
您试图与ob_gzhandler?
are you tried with ob_gzhandler?
<?php
ob_start("ob_gzhandler");
?>
<html>
<body>
<p>This should be a compressed page.</p>
</html>
<body>
提示:有时是pretty的棘手的检测,如果网络被发送COM pressed与否,我使用Firefox的萤火虫插件,我测试了一个PHP文件,而不COM pression和COM pression并比较大小,在我的情况,差异有1MB(非COM pressed)和56KB COM pressed。
tip: sometimes is pretty tricky to detect if the web is send compressed or not, i use firefox's firebug plugin, i tested a php file without compression and with compression and compare the size, in my case, the difference was 1mb (non compressed) and 56kb compressed.
或在您的.htaccess
Or in your .htaccess
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</IfModule>
这篇关于如何启用gzip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!