First of all, make sure Apache deflate module is enabled on your system. The below command will enable the deflate module for in Apache on Debian based systems. This tutorial has been tested on Ubuntu 18.04.
sudo a2enmod deflate
Then edit the module configuration file in your favorite text editor.
Advertisement
sudo vim /etc/apache2/mods-enabled/deflate.conf
Then add “AddOutputFilterByType DEFLATE application/json” in the deflate module configuration file.
1 2 3 4 5 6 7 8 9 | <IfModule mod_deflate.c> <IfModule mod_filter.c> AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/json </IfModule> </IfModule> |
Save your file and restart Apache2 service to apply new settings.
systemctl restart apache2.service
All done.