Reputation: 13537
I am making a call to an endpoint that returns JSON. When I save the data to a file, the total size is 500 Kilobytes. What I wanted to do was to compress the JSON, but I heard by just enabling compression on the web server (Apache), I will accomplish the same thing. Now I have done that, and enabled compression. But how do I get the size of the DOWNLOAD, and not the size of the file if I save it?
Upvotes: 0
Views: 129
Reputation: 1965
It's not quite as simple as just enabling compression on the web server. The HTTP request received by the server must include the Accept-Encoding
header to indicate which compression scheme or schemes it support.
The most common is: Accept-Encoding: gzip
.
You'd likely need to use a packet sniffer (fiddler or equivalent) to determine the difference in payload sizes when compressed versus decompressed. Most HTTP libraries I am aware of decompress the payload before passing it back to the calling code.
Upvotes: 1