2

I want to compress my API responses above a certain threshold. I'm using Grails 3.0.11 and since Grails uses spring boot underneath it, I used Spring configurations to enable response compression. I used following configuration snippet in my application.yml:

server:
    compression:
        enabled: true
        mime-types: application/json,application/xml,text/html,text/xml,text/plain
        min-response-size: 2048

This should work as mentioned in many tutorials for spring boot, but it isn't working for me because when I hit any API with response size greater than 2048 bytes, I don't get content-encoding=gzip response header. What am I doing wrong?

I used these configurations from here: http://bisaga.com/blog/programming/web-compression-on-spring-boot-application/

I'm testing my APIs using postman. That can be a culprit too.

Update

From this question, I got the idea of the difference between configurations for different spring-boot versions. My current spring-boot version is 1.2.7. So I tried to use following configurations too but to no avail:

server:
    compression:
        enabled: on
        compressableMimeTypes: application/json,application/xml,text/html,text/xml,text/plain
        min-response-size: 2048
Saqib Ahmed
  • 1,056
  • 14
  • 33
  • Is there anything else in between your postman and your service? Like another proxy that may not be allowing that header through? – DaShaun Jan 26 '18 at 07:55
  • Nope. I'm using it directly from embedded tomcat. And it is mentioned in the documentation that these configurations work with embedded tomcat. – Saqib Ahmed Jan 26 '18 at 07:56

0 Answers0