启用 mod_deflate 发送 Content-Encoding: gzip

发布于 2024-07-20 07:25:26 字数 1308 浏览 8 评论 0原文

编辑我发现问题实际上是php minify。 这是发送压缩的内容而不是 Apache。 我会找到更多这方面的信息。

根据 高性能网站,如果我在 Apache 2.x 中启用 mod_deflate,请添加以下行,它应该发送 gzipped/delfated 内容: -

AddOutputFilterByType DEFLATE text/html text/css application/x-javascript

书上还说 gzipdeflate 更有效。

我已通过添加同一行在 httpd.conf 中启用。 但 Apache 发送 Content-Encoding: deflate

我使用 CURL 进行了测试: -

curl -i -H "Accept-Encoding: gzip" "http://192.168.1.33/s.js" >> e:\curl_log.txt

它返回“gzipped”内容。 但是当我发送命令时: -

curl -i -H "Accept-Encoding: gzip, deflate" "http://192.168.1.33/s.js" >> e:\curl_log.txt

它返回“压缩”内容。

因此,如果浏览器同时支持 deflated 和 gzipped,Apache 会发送 deflated。 如何告诉 Apache 更喜欢 gzip 而不是 deflate?

仅供参考:-

EDIT I have found that the problem is actually php minify. This was sending the deflated content instead of Apache. I'll find more on this.

According to High Performance Web Sites, if I enable mod_deflate in Apache 2.x, by adding the following line, it should send gzipped/delfated content: -

AddOutputFilterByType DEFLATE text/html text/css application/x-javascript

The book also says that gzip is more effective than deflate.

I have enabled in httpd.conf by adding the same line. But Apache sends Content-Encoding: deflate.

I tested with CURL using: -

curl -i -H "Accept-Encoding: gzip" "http://192.168.1.33/s.js" >> e:\curl_log.txt

It returns 'gzipped' content. But when I send the command: -

curl -i -H "Accept-Encoding: gzip, deflate" "http://192.168.1.33/s.js" >> e:\curl_log.txt

It returns 'deflated' content.

So, if the browser supports both deflated and gzipped, Apache send deflated. How to tell Apache to prefer gzip over deflate?

FYI: -

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

め七分饶幸 2024-07-27 07:25:26

据我所知,原因已经找到了。 为了进一步帮助摆脱可能的混乱:

  • mod_deflate 尽管其名称目前仅支持 gzip。

  • gzip 更“有效”,因为以下原因

deflate - 尽管它的名称是 zlib 压缩 (RFC 1950),但应该按照 RFC 2616 中的描述使用(与 deflate 压缩 (RFC 1951) 结合使用)。然而,现实世界中的实现似乎在 zlib 之间有所不同压缩和(原始)放气压缩[3][4]。 由于这种混乱,gzip 将自己定位为更可靠的默认方法(2011 年 3 月)。

gzip 和 zlib 是文件/流格式,默认情况下环绕 deflate,并添加校验和,这使它们更安全且速度稍慢。 另一方面,尺寸的增加不应引起任何关注。

另请参阅 HTTP_compression - Wikipedia

As I see the cause was already found. To further on help getting out of possible confusions:

  • mod_deflate despite its name is currently only supporting gzip.

  • gzip is more "effective" because of the following

deflate - despite its name the zlib compression (RFC 1950) should be used (in combination with the deflate compression (RFC 1951)) as described in the RFC 2616. The implementation in the real world however seems to vary between the zlib compression and the (raw) deflate compression[3][4]. Due to this confusion, gzip has positioned itself as the more reliable default method (March 2011).

gzip and zlib are file/stream formats that by default wrap around deflate and amongst other things add a checksum which make them more secure and a little slower. The increase in size on the other hand should not be of any concern.

Also see HTTP_compression - Wikipedia

笑脸一如从前 2024-07-27 07:25:26

请参阅 http://httpd.apache.org/docs/2.0/mod/mod_deflate .html 了解所有血淋淋的细节——您确定在配置中的其他地方没有出现 no-gzip 吗? 当您改变“浏览器”时会发生什么,例如使用 wget 以及不同的 -U 值?

See http://httpd.apache.org/docs/2.0/mod/mod_deflate.html for all the gory details -- are you sure you don't have occurrences of no-gzip elsewhere in the configuration? What happens as you vary your "browser", e.g. by using wget with various values for -U?

新一帅帅 2024-07-27 07:25:26

我怀疑您用来测试的任何内容都没有

发送 ... Accept-Encoding: gzip ... 。

在请求标头中

I suspect whatever you're using to test is not sending ...

Accept-Encoding: gzip

... in the request header.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文