How to enable gzip in traccar server jetty 10.0.4

sameh2 years ago

Greetings,

i would like some help with configuring jetty server to enable gzip compression for web static content, i need this because the content being served
in the modern version is too big to be handled by the low bandwidth we have in our country > 3.8 MB .

i noticed that in the WebServer.java code a gzip Handler is being used and is added to the servlet , but this still doesn't compress the data, I know this because the response headers that are being returned by the server do not contain content-encoding.

so i added these few lines to the code:

// in the InitWebApp method
servletHolder.setInitParameter("gzip", "true"); 

...
// in the WebServer constructor
GzipHandler gzipHandlerRES = new GzipHandler();
gzipHandlerRES.setIncludedMimeTypes("text/html","text/plain","text/xml","text/css","application/javascript","text/javascript");
gzipHandlerRES.setIncludedMethods("GET");
handlers.addHandler(gzipHandlerRES );
server.setHandler(handlers);

but unfortunately this still doesn't work, i need some help with this please. or atleast how do i debug the issue.
Additionally after i did a lot of research on the subject i believe the way to configure gzip compression in older version of jetty like 9.4 is different
they use some kind of gzip filter class, so Iam a bit confused with this

Anton Tananaev2 years ago

The right solution would be to have a proxy that does compression and anything else you need, like SSL, caching etc.

sameh2 years ago

so is it not possible to do this alone using jetty? without any reverse proxy?

Anton Tananaev2 years ago

I'm sure it's possible, but I don't think that's the right solution.

Santiago2 years ago

Good morning Sameh, were you able to solve this? I have exactly the same problem and I think that this must be the solution.