Posted on 2011-08-24 10:56
贝贝爸爸 阅读(291)
评论(0) 编辑 收藏 所属分类:
J2EE
由于工作需要偶然间发现一个很好的项目,能够对web开发经常遇见的js,css文件过大压缩的问题,项目地址是:
webutilities,
具体用法如下:
<filter>
<filter-name>compressionFilter</filter-name>
<filter-class>com.googlecode.webutilities.filters.CompressionFilter</filter-class>
<init-param>
<param-name>compressionThreshold</param-name>
<param-value>1024</param-value> <!-- compress anything above 1kb -->
</init-param>
<init-param>
<param-name>ignoreURLPattern</param-name>
<param-value>.*\.(flv|mp3|mpg)</param-value> <!-- regex -->
</init-param>
<init-param>
<param-name>ignoreMimes</param-name>
<param-value>images/*,video/*, multipart/x-gzip</param-value> <!-- ignore -->
</init-param>
<init-param>
<param-name>ignoreUserAgentsPattern</param-name>
<param-value>.*MSIE.*</param-value> <!-- regex -->
</init-param>
</filter>
<filter-mapping>
<filter-name>compressionFilter</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>
一切ok,再通过firebug观察js的请求,已经减少了大半,并且内容压缩类型为:gzip了。