WordPress REST API json – How to activate gzip compression?

I used your exact set of .htaccess directives to achive json gzip’ing. Took my files from 23k to 4k.

So I would assume its one of the two following things:

  1. Your.htaccess is not allowed to use these directives so it ignores them. Thus you either need to do one of the following: a) edit the httpd.conf or /etc/apache/sites-available/site.conf or httpd-vhosts.conf (depending on the system you are on) and add the gzip stuff there. b) edit the same files and give your.htaccess the rights to override these settings. c) check your are really running apache so .htaccess works ;D
  2. Check that mod_deflate is loaded and if not, enable it. Again this might not be working as you are not running apache or the directives in the htttpd.conf (or wherever) do not cover application/json

If you do have .conf access to make these changes then put the deflate rules in there rather than in the .htaccess, that way the server learns about it at setup time, and not on every file access. increases speed (slightly).

If you do not have .conf access, you need to speak to the server people or hosting company and get them to add the AddOutputFilterByType DEFLATE application/json for your website, perhaps consider all of the settings you have done above.

As a bonus, if you really want uber small, Brotli compression was specifically made to make fonts smaller, and works on all file types. If you work with a host, ask them if this is possible also as well as gzip, so you have backwards compatibility.