I am sending large datasets in JSON format from my server (using PHP). I want to keep bandwidth costs down. I am wondering:
- should I gzip press the JSON data server side before sending the data?
- is there a javascript gzip unpression library?
I am sending large datasets in JSON format from my server (using PHP). I want to keep bandwidth costs down. I am wondering:
- should I gzip press the JSON data server side before sending the data?
- is there a javascript gzip unpression library?
3 Answers
Reset to default 5Yes, you should press your output (but only for transmission). But you can let your sever do it for you. If you use a standard pression on HTTP level the client will depress that automatically.
Yes, you should gzip press 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 press content on-the-fly (including dynamic content).
If you send this data to a grid you could reduce the sent data by paging the grid. This way only a certain number of rows is sent to the grid and the rest of the data will be sent on request.