如何压缩grails控制器的输出? [英] How to compress output from a grails controller?

查看:94
本文介绍了如何压缩grails控制器的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Grails 1.3.7控制器正在生成一些JSON&我想以压缩(压缩)形式将其发送到客户端,因为JSON的数量可以是2 + MB未压缩。我发现的资源插件似乎只压缩静态资源。还有一种方法可以压缩动态控制器的输出吗?解析方案

如果你正在从一个基于web的应用程序中为你的grails应用程序提供服务,像apache或nginx这样的服务器,你可以很容易地在前端配置压缩。

请参阅 mod_deflate for apache and HttpGzipModule 对于nginx。



如果您希望在jar中进行压缩工作,您可以创建 ServletFilter 并自己做压缩就像在这个SO问题中提到的那样,或者使用像dmahapatro 提到的UI-Performance插件 。 p>

My Grails 1.3.7 controller is generating some JSON & I would like to send it to the client in compressed (zipped) form, as the amount of JSON can be 2+MB uncompressed. The resources plugin I found seems to compress static resources only. Is there a way to compress dynamic controller output as well?

解决方案

If you're serving your grails application from behind a web-server like apache or nginx, you can configure the compression in the front-end rather easily.

See mod_deflate for apache and HttpGzipModule for nginx.

If you would rather do the compression work inside your jar, you can either create a ServletFilter and do the compression yourself as mentioned in this SO question or use something like the UI-Performance plugin as mentioned by dmahapatro.

这篇关于如何压缩grails控制器的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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