【问题标题】:Testing if gzip is working locally测试 gzip 是否在本地工作
【发布时间】:2010-08-19 09:08:10
【问题描述】:

我有一个本地 wamp 设置并在 apache 中安装了 deflate_module。

我还在 .htaccess 中设置了以下规则。

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript text/javascript application/javascript application/json 

</IfModule>

但我如何测试它是否正常工作 - 我如何判断文件是否被 gzip 压缩?

谢谢!

【问题讨论】:

    标签: .htaccess gzip wamp compression


    【解决方案1】:

    我还建议使用curl (download here)

    命令是: curl --head --compressed @987654322@

    这将打印网页请求的标头。寻找写着:Content-Encoding: gzip 的行。如果它不存在,则说明您没有正确配置它。

    【讨论】:

      【解决方案2】:

      使用 netcat 并发送Accept-Encoding: gzip,deflate。如果返回压缩的 mumbo-jumbo,那么您的文件将被压缩。

      例子:

      GET / HTTP/1.1
      Host: www.yourdomain.org
      Accept: text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,image/jpeg,image/gif
      Accept-Language: en-us,en
      Accept-Encoding: gzip,deflate
      Connection: close
      

      不要忘记在末尾添加两个换行符。

      【讨论】:

      • 实际上 - 您不能在响应标头中查看“Content-Encoding : gzip”吗?以 Firefox 的 Firebug 为例。
      • 如果这对你有用,很好,我更喜欢 netcat 方法,因为我的大部分工作都是在控制台中完成的,并且我有类似的脚本。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-02
      • 2013-12-02
      • 2014-06-18
      • 1970-01-01
      • 1970-01-01
      • 2011-10-05
      相关资源
      最近更新 更多