问题描述
我在Wildfly服务器中配置GZip时出现问题,在服务器上使用了以下配置:
I'm with a problem to configure the GZip in my Wildfly server used the following configuration on the server:
<subsystem xmlns="urn:jboss:domain:undertow:1.2">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="gzipFilter" predicate="path-suffix['.css'] or path-suffix['.js'] or path-suffix['.xhtml']"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
<filters>
<response-header name="server-header" header-name="Server" header-value="Wildfly 8"/>
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow 1"/>
<gzip name="gzipFilter"/>
</filters>
</subsystem>
并正确成为请求的Zip文件,但是我想设置文件的最小大小要压缩和我很难,有人知道如何设置服务器的最小尺寸,然后将它们发送给客户吗?
And became the Zip file of the request correctly, however I would like to set the minimum size for files to be zipped and what I'm hard, anyone know how to set the minimum size for the server do the zip before sends them to the customer?
推荐答案
扩展Alexander的答案我做了一些测试。奇怪的是,谓词只压缩大于500字节的文件而不是min-content-size [500]
。
Expanding on Alexander's answer I did some tests. Strangely enough the predicate to only compress files larger then 500 bytes is not min-content-size[500]
.
使用 jboss-cli.sh配置它
运行此脚本:
/subsystem=undertow/configuration=filter/gzip=gzipFilter:add()
/subsystem=undertow/server=default-server/host=default-host/\
filter-ref=gzipFilter:add(predicate="not min-content-size[500]")
请注意gzip过滤器服务器重新加载后将开始工作。您可以使用cli的命令:reload
来执行此操作。
Note that the gzip filter will start to work after server reload. You can do this using cli's command :reload
.
要测试过滤器是否已启用,我使用了:
To test if the filter is enabled I used:
wget $MY_URL -S --header="accept-encoding: gzip" \
-O /dev/null 2>&1| grep Content-Encoding
这篇关于在Wildfly配置GZip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!