预期压缩内容
我在我的网站上启用了 gzip 压缩,并使用以下工具进行了测试:
- http://www.whatsmyip.org/ http_compression/
- http://www.gidnetwork.com/tools/gzip- test.php
- http://web-sniffer.net/
不过,Firefox 及其所有产品扩展程序(Firebug、Yslow 和 Google Page Speed)表示它们接收非压缩内容。
text/html 由 php 的 ob_gzhandler 压缩,它也关心 headers。
我不使用代理。
我究竟做错了什么?
I enabled gzip compression on my website, and tested with the following tools:
- http://www.whatsmyip.org/http_compression/
- http://www.gidnetwork.com/tools/gzip-test.php
- http://web-sniffer.net/
Though, Firefox and all its extensions (Firebug, Yslow and Google Page Speed) say they receive noncompressed content.
text/html is compressed by php's ob_gzhandler, which cares about headers as well.
I don't use proxy.
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这并不是您所期望的答案,但是您是否尝试过不使用 PHP 而是使用 Apache 来压缩数据?
这可以使用
mod_deflate
来完成。有几件事:
作为旁注:为了帮助我们找出 PHP 压缩出现的问题,您能否提供更多信息? 比如您网站的 URL(如果是公开的),以及一些代码?
编辑现在我们有了网址:http://ego.pestaa.hu/
当我转到该页面时,响应的标头如下:
(使用带 LiveHTTPHeaders 扩展的 firefox 3.5)
您指定的三个测试站点也表示您的页面已被 gzip 压缩。
你找到问题所在了吗?
您确定这不是来自您的浏览器的内容,它不会在请求中发送以下标头:
在其他答案后编辑
引用评论:
哦,如果问题不是你的网站,我想我完全误解了这个问题 - 对此感到抱歉:-( 我以为你不知道如何从你的网站服务器 gzip 压缩内容。
而且我想我不是唯一的一个,顺便说一句
如果问题与您网站的配置无关,那么,有两种可能性:
about:config
,network.http.accept-encoding
会说什么? 对我来说,如果问题来自于你的 ISP 或类似的东西,那就是gzip,deflate
,That's not really the answer you might expect, but did you try not compressing out data with PHP, but with Apache ?
This can be done use
mod_deflate
.Couple of things :
As a sidenote : to help us figure out what's going wrong with the compression by PHP, could you give more informations ? Like the URL of your site (if it's public), and some code ?
EDIT now that we have the URL : http://ego.pestaa.hu/
When I go to that page, the response's headers are as follow :
(using firefox 3.5 with LiveHTTPHeaders extension)
The three testing sites you indicated also say that your page is gzipped.
Did you find what the problem was ?
Are you sure this is not something coming from your browser, that would not send the following header in the request :
EDIT after other answer
Quote from the comments :
Oh, if the problem is not your website, I think I totally mis-understood the question -- sorry about that :-( I thought you didn't know how to server gzipped content from your website.
And I think I'm not the only one, btw
If the problem has nothing to do with your website's configuration, then, two possibilities :
about:config
, what does thenetwork.http.accept-encoding
say ? For me, it'sgzip,deflate
除了以下之外,还可以尝试 Live Http Headers firefox 插件其他。 它会打开一个窗口,显示来回时的确切请求/响应标头,因此您毫无疑问地知道接受编码和响应编码是什么。
Try the Live Http Headers firefox plugin in addition to the others. It opens a window showing the exact request/response headers as they go back and forward, so you know without doubt what the accept-encoding and response-encoding is.
您是否尝试过在 Apache/您的 Web 服务器中启用 gzip?
Have you tried just enabling gzip in Apache/your web server instead/as well?