0

gzip在 IBM HTTP Server v7.0 中启用了压缩。在响应标头中,我可以看到Varyaccept-encoding”。但是当我比较加载gzip和不加载的文件的大小时,gzip没有区别。我不确定我是否以正确的方式执行此操作。这是我在httpd.conf文件中添加的

LoadModule deflate_module modules/mod_deflate.so
AddOutputFilterByType DEFLATE text/html text/css application/x-javascript

你能帮我么?

4

1 回答 1

2

尝试以下代码并根据需要进行更改:

LoadModule deflate_module modules/mod_deflate.so

DeflateCompressionLevel 9
DeflateMemLevel 9
DeflateWindowSize 15

DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio

LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
CustomLog logs/deflate_log deflate

<Location />
    # Insert filter
      SetOutputFilter DEFLATE

    # Netscape 4.x has some problems...
      BrowserMatch ^Mozilla/4 gzip-only-text/html

    # Netscape 4.06-4.08 have some more problems
      BrowserMatch ^Mozilla/4\.0[678] no-gzip

    # MSIE masquerades as Netscape, but it is fine
      BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    # Don't compress images
      SetEnvIfNoCase Request_URI \
      \.(?:gif|jpe?g|png)$ no-gzip dont-vary

    # Make sure proxies don't deliver the wrong content
      Header append Vary User-Agent env=!dont-vary
</Location> 
于 2012-04-17T14:28:17.947 回答