Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sending large JSON data from server - should I compress?

I am sending large datasets in JSON format from my server (using PHP). I want to keep bandwidth costs down. I am wondering:

  1. should I gzip compress the JSON data server side before sending the data?
  2. is there a javascript gzip uncompression library?
like image 348
skyeagle Avatar asked Dec 01 '25 21:12

skyeagle


2 Answers

Yes, you should compress your output (but only for transmission). But you can let your sever do it for you. If you use a standard compression on HTTP level the client will decompress that automatically.

like image 107
Gumbo Avatar answered Dec 04 '25 09:12

Gumbo


Yes, you should gzip compress it — but at the web server level, not the application level. Then neither your server- nor client-side code needs to worry about it, it happens as part of the HTTP transfer. In Apache, for instance, you configure this via mod_deflate. In nginx, you use the Gzip module. Any half-decent web server will allow you to compress content on-the-fly (including dynamic content).

like image 30
T.J. Crowder Avatar answered Dec 04 '25 10:12

T.J. Crowder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!