java - mod_deflate 与 IBM WebSphere 和 IBM IHS

标签 java apache http websphere mod-deflate

我正在尝试为 css、js 和 html 资源启用响应压缩,这些资源捆绑为部署到 WebSphere v7 的 Web 应用程序的一部分。所有 HTTP 流量都路由到位于 WebSphere 实例前面的 IBM IHS HTTP 服务器。

我创建了一个 mod_deflate.conf 文件并将其导入到 httpd.conf 文件中。内容如下:

LoadModule deflate_module modules/mod_deflate.so

DeflateCompressionLevel 3

# 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>

# deflate.log, log compression ratio on each request 
<IfModule mod_deflate.c>
    DeflateFilterNote Input instream
    DeflateFilterNote Output outstream
    DeflateFilterNote Ratio ratio
    LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
    CustomLog logs/deflate.log deflate
</IfModule>

# Properly handle old browsers that do not support compression
<IfModule mod_deflate.c>
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

当我查看 HTTP 流量时,我看到请求指定可接受 gzip/deflate 编码:

Accept:"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
Accept-Encoding:"gzip, deflate" 

但是,响应没有被压缩(没有返回与 gzip/deflate 相关的 header ):

Content-Type:"text/html; charset=UTF-8"
Vary:"User-Agent"
Server:"IBM_HTTP_Server"

此外,deflate.log 没有显示发生任何压缩:

"GET /webapp/css/style.css HTTP/1.1" -/- (-%)
"GET /webapp/js/jquery/jquery.ui.draggable.min.js HTTP/1.1" -/- (-%)
"POST /webapp/markup/Basic.xhtml HTTP/1.1" -/- (-%)

Vary 响应 header 正在被发回,因此它肯定会命中声明 SetOutputFilter 的配置 block 。

我在这里缺少什么 - 内容不是根据过滤器/内容类型/资源名称匹配进行动态压缩吗?在上述情况下,所有与正则表达式不匹配的内容 .(?:gif|jpe?g|png|rar|zip)$ no-gzip 都应该被压缩,不是吗?

最佳答案

从数字上看——您查看的是来自客户端的原始 HTTP header ,而不是 WebSeal 发出的 hedaers,并且 WebSeal 决定剥离 Accept-Encoding,因此它本身不必担心多种变体相同的资源。

剥离可能可以通过某种晦涩的 webseal 方式进行配置。

关于java - mod_deflate 与 IBM WebSphere 和 IBM IHS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34155707/

相关文章:

java - 获取给定 java Map 中的值的索引或键

java - 不同依赖包中有两个同名类时,如何指定期望的java类?

java - 在我的方法实例中找不到符号?

java - 实体的JPA集合字段是可修改的

multithreading - 如何通过一些约定使mod_perl解释器具有粘性?

http - HTTP 和 REST 有什么区别?

image - 银联银行 : Can't I download image with a URL?

html - “background-image” 样式在 IE 11 中不起作用

apache - Monit:在满足服务测试操作条件后延迟下一个监控周期

c - Libcurl 不会在重定向时发送 cookie