How to enable the Gzip compression in jBoss EAP server -
i using jboss eap 6.1 sevrer in want enable gzip compression html, css , javascript files.
i entirely new compression technology, can suggest me tutorial or can directly give me step wise process enable compression on jboss eap 6.1 server.
apart these have following doubts:
1) need compress files on workspace or if jboss server compression enabled take care of compression , need deploy war.
2) when server respond request , need explicitly convert or decode or decompress files use them or interpret them?
gzip compression web resources optional, can't compress of them , hope every web client able handle it. that's why it's enabled @ runtime when client (might web browser) says "gzip ok me" accept-encoding: gzip, deflate
header. see https://en.wikipedia.org/wiki/http_compression
on server side, magic handles http filter intercepts request, notes header, sends request on rest of app, intercepts response , compresses accordingly.
jboss has built-in support: enabling gzip compression jboss
if want yourself, need write filter
, configure in web.xml
.
public void dofilter(servletrequest req, servletresponse res, filterchain chain) throws ioexception, servletexception { if (req instanceof httpservletrequest) { httpservletrequest request = (httpservletrequest) req; httpservletresponse response = (httpservletresponse) res; string ae = request.getheader("accept-encoding"); if (ae != null && ae.indexof("gzip") != -1) { gzipresponsewrapper wrappedresponse = new gzipresponsewrapper(response); chain.dofilter(req, wrappedresponse); wrappedresponse.finishresponse(); return; } chain.dofilter(req, res); } }
or can use performance optimization library webutilities enable compression described here https://github.com/rpatil26/webutilities/wiki/enable-compression
see also:
Comments
Post a Comment