I am working on Playframework 2.x application. The controllers in my application return JSON response back to the browser/endpoint. I wanted to know if there is a simple way to enable GZIP compression of the response bodies.
相关问题
- PlayFramework: how to transform each element of a
- Could not import the newly generated play framewor
- Play Framework Unicode symbols in HTTP Header
- Play framework 2 : How to pass object between rout
- Putting output of 'git describe' in templa
相关文章
- how to set H2 primary key id to auto_increment?
- Testing request with CSRF Token in Play framework
- How to map an abstract collection with jpa?
- Build maven project as a part of SBT build
- play2 framework my template is not seen. : package
- How does @Inject in Scala work
- play framework 2.0 - unexpected exception - Key No
- Fiddler doesn't decompress gzip responses
gzip'ing is pretty much complete cake with an Apache front end.
On Apache 2.4 gzip handling via
Location
block using a basic set of content types might look like:Currently in play 2.0.4 there is no simple way for non assets.
For the Java API you could use:
In
Play framework 2.2+
it is possible to use GzipFilter. Available via sbt:If you are a scala guy, it is worth looking at Gzip class.
With Play 2.5, as mentioned here:
Here's a sample code to include gZip Filter(along with a sample CORS filter to showcase adding multiple filters):