【问题标题】:Omnifaces Gzip compression not compressing inspite of Accept-Encoding : gzip,deflate set尽管接受编码,Omnifaces Gzip 压缩不压缩:gzip,deflate set
【发布时间】:2015-07-21 13:15:49
【问题描述】:

我正在使用 Omnifaces 1.7/primefaces 5.2 /jsf 2.0/J2ee 5/weblogic 10.3/IE 11。

我已经设置了 GzipResponseFilter 来为我的 webapp 启用压缩。尽管添加了以下配置,但我没有看到浏览器中收到的响应大小有任何差异。我正在使用 IE11 及其调试器工具来检查响应大小。我还看到 Accept-Encoding - gzip,deflat - 从 IE11 传入请求标头。任何人都可以帮助我了解为什么我看不到压缩工作。下面是web.xml?

<filter>
    <filter-name>gzipResponseFilter</filter-name>
    <filter-class>org.omnifaces.filter.GzipResponseFilter</filter-class>
    <init-param>
        <param-name>threshold</param-name>
        <param-value>150</param-value> <!-- size larger than 150 should be compressed -->
    </init-param>
    <init-param>
        <param-name>mimetypes</param-name>
        <param-value>
     text/plain, text/html, text/xml, text/css, text/javascript, text/csv, text/rtf,
     application/xml, application/xhtml+xml, application/javascript, application/json
        </param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>gzipResponseFilter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>ERROR</dispatcher>
</filter-mapping>

【问题讨论】:

  • 您在响应编码中看到了什么?可能只是显示未压缩的大小。
  • 在 IE 调试器的响应标头中,我看到的唯一与编码相关的内容如下。传输编码分块
  • 耐心是一种美德。如果事情很紧急,请在某处获得商业支持
  • 我猜想在 IE 调试器中寻找压缩响应大小是错误的。 IE 显示解压后的响应大小。我应该使用提琴手来检查响应大小。一旦我检查提琴手,将更新帖子。

标签: jsf-2 primefaces gzip omnifaces


【解决方案1】:

尝试使用不同的 URL 模式

<filter-mapping>
    <filter-name>gzipResponseFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>ERROR</dispatcher>
</filter-mapping>

有关我如何执行此操作的更多详细信息,请参阅以下链接 https://*.com/a/35567295/5076414

【讨论】:

    最近更新 更多