Check the deflate module is available:
Run this on command line:
apachectl -t -D DUMP_MODULES |grep deflate
Should show deflate_module (shared)

Then we just need to add a line to the deflate config:
sudo nano /etc/apache2/mods-enables/deflate.conf

Add the following line to the list:
AddOutputFilterByType DEFLATE application/json

Restart apache (sudo /etc/init.d/apache2 restart)
Test by requesting json output from server and inspecting the response headers in Developer Tools. Should see a content encoding header like “Content-Encoding:gzip”