PLA Tech Blog   

Apache Deflate Does Not Include application/json

Discovered using Google Chrome’s audit tool that json was not compressed (gzip). Turns out Apache doesn’t include application/json in the deflate module configuration file.

I added application/json to /etc/apache2/mods-enabled/deflate.conf and now JSON is gzipped.

The complete file looks like this:

<IfModule mod_deflate.c>
	<IfModule mod_filter.c>
		# these are known to be safe with MSIE 6
		AddOutputFilterByType DEFLATE text/html text/plain text/xml

		# everything else may cause problems with MSIE 6
		AddOutputFilterByType DEFLATE text/css
		AddOutputFilterByType DEFLATE application/json application/x-javascript application/javascript application/ecmascript
		AddOutputFilterByType DEFLATE application/rss+xml
		AddOutputFilterByType DEFLATE application/xml
	</IfModule>
</IfModule>

I am running Apache/2.4.7 frontend with Tomcat/8.0.15 backend. Both are on Ubuntu 14.04 VMs.

Written on May 24, 2018.