Configuration GZip at Wildfly

↘锁芯ラ 提交于 2019-12-03 12:40:12

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].

To configure it using jboss-cli.sh run this script:

/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]")

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

There is a predicate in undertow min-content-size so you can use predicate=min-content-size[500]

I found the available predicates here https://github.com/undertow-io/undertow/tree/master/core/src/main/java/io/undertow/predicate due to lack of documentation

It worked with the predicate:

predicate="exists['%{o,Content-Type}'] and regex[pattern='(?:application/javascript|text/css|text/html|text/xml|application/json)(;.*)?', value=%{o,Content-Type}, full-match=true]"
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!