尽管日志文件说它会压缩,但 Apache mod_deflate 不会压缩 [英] Apache mod_deflate doesn't compress although logfile says it would

查看:20
本文介绍了尽管日志文件说它会压缩,但 Apache mod_deflate 不会压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着用谷歌搜索这个,但到目前为止没有成功.我在 Debian 上有一个 apache 2.2.16,加载并启用了 mod_deflate,如下所示:

I tried googling this by hard but was unsuccessful so far. I've got an apache 2.2.16 on Debian with mod_deflate loaded and enabled like this:

LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so

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

DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%) "%{User-agent}i"' deflate
CustomLog /var/log/apache2/deflate_log deflate env=!trash

当我打开一个页面时,日志文件说它正在压缩我的 CSS 文件(和其他文件):

When I open a page the log file says that it's compressing my CSS file (and others):

"GET / HTTP/1.1" -/- (-%) "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17"
"GET /www/js/dojoToolkit/dijit/themes/claro/claro.css HTTP/1.1" 17244/118618 (14%) "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17"
"GET /www/css/basis-min.css HTTP/1.1" 10877/61154 (17%) "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17"

但是 Firebug 和 Chrome 仍然可以获取未压缩的文件,尽管明确接受 gzip 和 deflate 编码.一个有趣的事实是

But Firebug and also Chrome do still get the uncompressed files, although the explicitly accept gzip and deflate encoding. One interesting fact is also that the

Vary: Accept-Encoding

header 仍然设置,不像 Content-Encoding:

header is still set, unlike the Content-Encoding:

GET /www/js/dojoToolkit/dijit/themes/claro/claro.css HTTP/1.1
Host: www.getabstract.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17
Accept: text/css,*/*;q=0.1
Accept-Language: en-us,de-ch;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://www.getabstract.com/
Cookie: __utma=73758084.1377620539.1310985055.1310989511.1310990668.3; __utmz=73758084.1310985055.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); fpc10001731534234=Y63gTWM9|aCXc2doLaa|fses10001731534234=|aCXc2doLaa|Y63gTWM9|fvis10001731534234=Zj1odHRwJTNBJTJGJTJGd3d3LmdldGFic3RyYWN0LmNvbSUyRiZiPUhvbWVwYWdlJTIwRU4=|8M8Y7oT7YH|8M8Y7oT7YH|8M8Y7oT7YH|8|8M8Y7oT7YH|8M8Y7oT7YH; __ar_v4=262MD4C3UNHKBELB3VUEGS%3A20110717%3A20%7CTBE3U4YYEBCGHJ2QAUBVE4%3A20110717%3A20%7CXVIJYAN7KFDQXPECC3AI7E%3A20110717%3A20; JSESSIONID=abcKrMR5EVQv68Os6h9et; __utmc=73758084
Pragma: no-cache
Cache-Control: no-cache

回复:

HTTP/1.1 200 OK
Date: Mon, 18 Jul 2011 13:54:45 GMT
Server: Apache
Last-Modified: Wed, 04 May 2011 10:49:12 GMT
Etag: "28023a-1cf5a-4a27101cc1a00"
Accept-Ranges: none
Cache-Control: max-age=600
Expires: Mon, 18 Jul 2011 14:04:45 GMT
Vary: Accept-Encoding
Content-Length: 118618
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Content-Type: text/css

有什么想法吗?

提前致谢.马克

推荐答案

远景:apache 是否正确处理了您的 css 文件 - 即 mime 类型配置是否正确?

Long shot: is apache treating your css file correctly - i.e. are the mime types configured correctly?

您的输出过滤器设置在哪里,在包含的配置中或在 .htaccess [检查 .htaccess 是否允许覆盖]

Where is your output filter set, in an included config or in an .htaccess [check that .htaccess is allowed to override]

你能去掉过滤器吗?看看它是否会压缩所有内容?

Can you remove the filter & see if it will compress all content?

最后 - 是否有我们可以测试的公共 URL?

Lastly - is there a public URL we can test?

-肖恩

您好,您使用什么进行本地测试?我可以在 firefox/firebug/yslow 中看到正确的内容编码.- [我还看到了其他几个问题] - 如果您没有使用 firebug,我建议您[强烈!] 检查一下 - 但是,是的,看起来您的压缩工作正常.

Hi Again, what are you using to test locally? I can see the correct content encoding in firefox/firebug/yslow. - [I also see several other issues] - if you are not using firebug, I suggest checking it out [strongly!] - but otherwise, yes, it appears your compression is working correctly.

-肖恩

这篇关于尽管日志文件说它会压缩,但 Apache mod_deflate 不会压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆