使用gzip压缩组件 - Java EE [英] Compress components with gzip - Java EE

查看:144
本文介绍了使用gzip压缩组件 - Java EE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望改善应用程序的前端性能,所以我在Firefox中使用了YSlow工具。当我为我的应用程序运行此工具时,在YSlow等级选项卡中,它出现了使用gzip压缩组件的F级问题。似乎是我们需要在从服务器发送到客户端时压缩文件(js,css)以增加服务器响应时间。

I am looking to improve front-end performance of my application, so I used YSlow tool in Firefox. When I ran this tool for my app, in the YSlow grade tab it showed up a issue 'Grade F on Compress components with gzip'. Seems to be that we need to compress the files(js, css) while sending from the server to client to increase the server response time.

我的应用程序是Struts Java应用。任何人都可以让我知道如何从服务器压缩和发送前端UI文件(JS,CSS),以便响应时间增加,我的页面很快?在服务器上用Java压缩这些文件需要做些什么?

My app is a Struts Java application. Can anyone let me know how to compress and send the front end UI files(JS,CSS) from server so that the response time increases and my pages lot fastly? What are the things that I need to do to compress these files in Java at server?

推荐答案

我建议使用 Servlet过滤器(自servlet 2.3规范以来)

I recommend to use a Servlet Filter (since servlet 2.3 spec)

gzip过滤器有详细记录,因此无需重新发明轮子:

A gzip filter is well documented, so there is no need to reinvent the wheel:

  • http://raibledesigns.com/rd/entry/the_battle_of_the_gzip
  • http://onjava.com/pub/a/onjava/2003/11/19/filters.html

此外,一些servlet容器可以动态执行gzip。请查看此相关问题

Also, some servlet containers can do gzip on the fly. Take a look at this related question.

这篇关于使用gzip压缩组件 - Java EE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆