【问题标题】:YSlow tells me site is not compressed even though it isYSlow 告诉我网站没有压缩,即使它是
【发布时间】:2011-04-02 02:30:31
【问题描述】:

"使用 gzip 压缩组件的 F 级

有 19 个纯文本组件应压缩发送"

我已经使用“http://www.whatsmyip.org/http_compression/”单独检查了主页的压缩以及所有 19 个组件,它显示了所有组件的压缩。此外,我确保我没有使用代理,并且“Accepting-Encoding”是使用“http://www.lagado.com/proxy-test”的 gzip/deflate。与这些结果相反,mod_deflate 日志文件如下(摘录):

...“GET / HTTP/1.1”4498/13306 (33%) “GET /Home_Page/style.css HTTP/1.1” -/- (-%) "GET /css/style.css HTTP/1.1" -/- (-%) "GET /css/slimbox.css HTTP/1.1" -/- (-%) "GET /js/validator_o.js HTTP/1.1" -/- (-%) ...

所以它没有压缩 css 或 js 文件?我的配置文件如下:

<IfModule mod_deflate.c>    SetOutputFilter DEFLATE

AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript text/xml image/svg+xml application/javascript application/x-javascript application/atom_xml application/rss+xml application/xml application/xhtml+xml application/x-httpd-php application/x-httpd-fastphp

SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.avi$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.mov$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.mp4$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.rm$ no-gzip dont-vary

   BrowserMatch ^Mozilla/4 gzip-only-text/html    BrowserMatch ^Mozilla/4\.0[678] no-gzip    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    DeflateFilterNote Input instream
    DeflateFilterNote Output outstream
    DeflateFilterNote Ratio ratio
    LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
    CustomLog /etc/httpd/logs/deflate_log deflate </IfModule>

火狐 3.6.8 视窗 7 专业版 ISP:罗杰斯

【问题讨论】:

    标签: apache compression yslow mod-deflate


    【解决方案1】:

    没关系,现在可以了。我将修改后的配置文件设置如下

    # Method 2: Compress all content, manually excluding specified file types
    <IfModule mod_deflate.c>
      # place filter 'DEFLATE' on all outgoing content
      SetOutputFilter DEFLATE
      # exclude uncompressible content via file type
      SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|rar|zip)$ no-gzip
      <IfModule mod_headers.c>
        # properly handle requests coming from behind proxies
        Header append Vary User-Agent
      </IfModule>
    </IfModule>
    

    然后重新加载浏览器缓存并检查日志文件并进行压缩。 Yslow 同意了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多