Moving compression from the web server into the application changes who pays for it, and makes one small payload size the deciding factor.

There is a version of API performance work that consists of adding a header and moving on. Turn on gzip at the web server, set Accept-Encoding, and let the infrastructure handle the rest. That works until it does not: a shared host you cannot configure, a proxy that strips the header, or an endpoint where you want compression on one route but not another.
The team behind a 2023 study in the Journal of Information Technology and Computer Science took the other path. They moved compression into the application itself, so the API code decides what happens to each response before it leaves the server.

Compressing inside the application trades flexibility in one direction for flexibility in another. The server does more work, and the client has to decode the result on its own. In exchange, the behaviour travels with the code instead of depending on an environment somebody else controls.

The most portable finding is a number. Below about 150 bytes of JSON, compressing makes a response larger rather than smaller. A 68 byte payload arrived as 112 bytes. A 135 byte payload arrived as 144 bytes. The cause is Base64, which encodes every three bytes of Zlib output as four characters.
Above that line the picture flips. Payloads from roughly 12.5 kilobytes upward came back at about a third of their original size, saving up to 66 percent of the transfer volume.
The authors are careful about scope. They measured a single API function from a transport navigation service, applied no caching or pagination, and did not benchmark against native HTTP compression. Those gaps are the obvious next study. For now the takeaway is a habit: pick a size threshold, compress above it, and leave the small responses alone.
Pinandito, A., Kharisma, A.P., Jonemaro, E.M.A. (2023). Architectural Design of Representational State Transfer Application Programming Interface with Application-Level Base64-Encoding and Zlib Data Compression. Journal of Information Technology and Computer Science.