Trying to enable gzip in Jetty for js/css files

505 views
Skip to first unread message

Jonathan Brookins

unread,
Mar 20, 2015, 12:37:17 PM3/20/15
to lu...@googlegroups.com
I've been trying to add gzip compression for javascript and css files on my local machine which is using Jetty with no success.  I read this http://www.eclipse.org/jetty/documentation/9.1.2.v20140210/gzip-filter.html but I cannot find a web.xml file, although there is a webdefault.xml which looks promising.  When I add that filter block into the file nothing works.  It crashes with a 503 Service Unavailable.  The lucee console shows no error messages, and I cannot find any jetty logs.  Anyone have any ideas on my debugging of the Jetty issue, or has this already setup?  Thanks!

Terry Whitney

unread,
Mar 20, 2015, 2:31:51 PM3/20/15
to lu...@googlegroups.com
In \were-ever-you-extracted-lucee-express-installer\conf\ is where you will find web.xml


I would make a backup copy of that file before you attempt to do anything else.

Igal @ Lucee.org

unread,
Mar 20, 2015, 2:40:28 PM3/20/15
to lu...@googlegroups.com
the /conf/web.xml is a Tomcat path, not Jetty.

in both engines (as well as any other servlet engine) you can place a web.xml in your app's WEB-INF folder, so it would be /{your-web-context}/WEB-INF/web.xml -- it will, of course, have to be valid as per the Servlet specification.

otherwise, in Jetty, you can simply modify webdefault.xml, which is equivalent to {Tomcat}/conf/web.xml

if you don't know what you're doing then definitely make a backup.  if you know what you're doing then also make a backup ;)

Igal Sapir
Lucee Core Developer
Lucee.org

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/8c0ff9cf-1284-4e43-8601-92148133f9d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Terry Whitney

unread,
Mar 20, 2015, 2:56:14 PM3/20/15
to lu...@googlegroups.com
Sorry about that.

Only how many web servers are there?

:)

I would run an override as described here, as it seems like the cleaner approach.






On Friday, March 20, 2015 at 12:37:17 PM UTC-4, Jonathan Brookins wrote:

Igal @ Lucee.org

unread,
Mar 20, 2015, 2:58:24 PM3/20/15
to lu...@googlegroups.com
I'm pretty sure that this list is not complete, but it probably covers most Servlet containers:
http://en.wikipedia.org/wiki/Web_container#List_of_Servlet_containers


Igal Sapir
Lucee Core Developer
Lucee.org

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.

Jonathan Brookins

unread,
Mar 20, 2015, 3:10:18 PM3/20/15
to lu...@googlegroups.com
Thanks for the clarification, Igal.  Adding that <filter> block seems to prevent Jetty from working.  Once removed everything is back to normal.  Does Jetty automatically log exceptions anywhere?

Igal @ Lucee.org

unread,
Mar 20, 2015, 3:16:34 PM3/20/15
to lu...@googlegroups.com
1) what version of Jetty are you using?  log files should be in default folder so you should check out the Jetty docs.

2) if you are after optimizing the performance of your servers then you should really front Lucee with a web server like nginx (or Apache httpd or MS IIS).

3) if you placed the filter element in the right place then most likely the class file org.eclipse.jetty.servlets.GzipFilter is not in the classpath, you should download the jar from the Maven repository.  I still recommend item (2) above though.


Igal Sapir
Lucee Core Developer
Lucee.org

Jonathan Brookins

unread,
Mar 20, 2015, 4:28:28 PM3/20/15
to lu...@googlegroups.com
This is just on my development laptop.  The Jetty version is 9, the install is whatever the original Railo install did.  I'll check on the GzipFilter class.  This isn't urgent at all, thanks for the suggestions.

Andrew Penhorwood

unread,
Mar 21, 2015, 11:51:32 AM3/21/15
to lu...@googlegroups.com
Here is the filter block XML.  I added it to my webdefault.xml above the default context stuff.  You could also add it to web.xml if you only want to run it for that context.  If you go the web.xml route make sure the file is proper XML.  

<filter>
<filter-name>GzipFilter</filter-name>
<filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class>
<init-param>
<param-name>methods</param-name>
<param-value>GET,HEAD</param-value>
</init-param>
<init-param>
<param-name>mimeTypes</param-name>
<param-value>text/html,text/css,text/plain,text/xml,application/javascript</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>GzipFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>


On the default context parameters you will need to turn on gzip.

<init-param>
<param-name>gzip</param-name>
<param-value>true</param-value>
</init-param>

When asking questions about Jetty it is better to use the jetty user mailing list.

Andrew Penhorwood


Peter Boughton

unread,
Mar 22, 2015, 3:30:29 PM3/22/15
to Jonathan Brookins, lu...@googlegroups.com
Jonathan wrote:
> This is just on my development laptop.

Well the point of gzip is to compress files for faster network transfer.
If there's no real network involved, there's likely no benefit doing it.
(Other than the educational benefits of learning how it's done.)


> The Jetty version is 9, the install
> is whatever the original Railo install did.

You presumably mean Jetty 9.1.5 that came with Railo Express 4.2.1?

If someone asks a version number, always specify at least major.minor,
and there's no harm in giving the full major.minor.patch.build version.

You can get these values for any Lucee/Railo server by dumping server
scope.


Anyhow, to enable gzip for static files you need to do *two* things:

1) Add the filter and filter-mapping config to etc/webdefault.xml

2) Add "--module=servlets" to start.ini

This second step enables Jetty to find the GzipFilter class (which is
in jetty-servlets.jar and only loaded if servlets module is enabled).

That works on the above mentioned versions - if it still doesn't work
for you we'll need to either turn on logging to find out why, or just
use a fresh setup (which is probably the easier/better route if you
don't have any customisations to keep).

Peter Boughton

unread,
Mar 22, 2015, 3:45:19 PM3/22/15
to lu...@googlegroups.com
Andrew wrote:
> On the default context parameters you will need to turn on gzip.
>
> <init-param>
> <param-name>gzip</param-name>
> <param-value>true</param-value>
> </init-param>

That parameter doesn't turn on gzip, it turns on looking for
already-gzipped files.

So if the request is for /styles.css and there is a /styles.css.gz file
then Jetty will send the latter in response.

Saves the overhead of compressing the file at request time, so a useful
final step if a CSS pre-processor is used, but otherwise it's probably
annoying to have to keep the file in sync when changes are made.



> When asking questions about Jetty it is better to use the jetty user
> mailing list.

And when suggesting someone to use another mailing list, it's useful to
point them at it. :P

https://dev.eclipse.org/mailman/listinfo/jetty-users

Michael Offner

unread,
Mar 23, 2015, 3:12:18 AM3/23/15
to lu...@googlegroups.com
As a sitenote, if you use .cfm as extension for your css/js files (style.css.cfm) Lucee is processing this requests and you can simply enable gzip compression in the lucee admin.

Micha
--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages