开发者

java: Easiest way to gzip all my webapp content with Jetty?

I have some large pages and javascript files being downloaded from a web app using Jetty. What is the easiest way to GZIP all my content. I am hoping for something where I just add开发者_如何学JAVA some lines to web.xml and add a jar file to WEB-INF/lib


In case you have your Jetty running behind a Apache Server via mod proxy you can use mod_deflate and then you have nothing to change at your web app at all.

See: Jetty/Tutorial/Apache and mod_deflate


You can use GzipFilter filter. I doing it like this:

<filter>
    <filter-name>GzipFilter</filter-name>
    <filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class>
    <init-param>
        <param-name>mimeTypes</param-name>
        <param-value>application/javascript,application/x-javascript</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>GzipFilter</filter-name>
    <url-pattern>/resources/*</url-pattern>
</filter-mapping>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜