Enable mod_deflate to send Content-Encoding: gzip

空扰寡人 提交于 2019-12-07 03:15:02

问题


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: -

  • I could not find anything in: http://httpd.apache.org/docs/2.0/mod/mod_deflate.html.
  • There is no occurrence of no-gzip in the Apache conf.
  • Server: Apache/2.2.9 (Win32) PHP/5.2.6
  • FF sends request header as: "Accept-Encoding: gzip, deflate"

回答1:


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

  • deflate would be more "efficient" (Frequently Asked Questions about zlib - What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings)



回答2:


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?




回答3:


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

Accept-Encoding: gzip

... in the request header.



来源:https://stackoverflow.com/questions/878068/enable-mod-deflate-to-send-content-encoding-gzip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!