The 30 second answer
For larger text responses like JSON, I enable gzip or brotli compression on the server or the load balancer. Text compresses very well, so transfer time drops a lot, especially on slow networks. I set a minimum size so tiny responses are not compressed, because the CPU cost is not worth it, and I skip already compressed content such as images.
Content-Encoding compresses the response body. Brotli (RFC 7932) usually compresses text better than gzip. In Spring Boot, set server.compression.enabled=true; it applies only above min-response-size (default 2KB). Spring Boot's embedded servers support gzip. Editor's note: brotli is usually handled at a proxy or CDN.