我努力用谷歌搜索,但到目前为止还没有成功。 我在Debian上有一个apache 2.2.16,mod_deflate加载并启用如下:
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文件(和其他人):
"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编码。
也是一个有趣的事实Vary: Accept-Encoding
标题仍然设置,与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
有什么想法吗?
提前致谢。 马克
答案 0 :(得分:0)
远射:是apache正确处理你的css文件 - 即mime类型是否配置正确?
您的输出过滤器在包含的配置或.htaccess中设置在哪里[检查.htaccess是否允许覆盖]
你可以删除过滤器&看看它是否会压缩所有内容?
最后 - 我们可以测试一个公共网址吗?
-Sean
编辑:
嗨再说一遍,你用什么来测试本地?我可以在firefox / firebug / yslow中看到正确的内容编码。 - [我还看到其他一些问题] - 如果你没有使用萤火虫,我建议[强烈!]检查它 - 但是否则,是的,看起来你的压缩工作正常。
-Sean