1

Im currently trying to activate the gzip compression on a Wordpress website. But the json output of the wordpress embed api doesn't seem to be affected by my htaccess settings.

Here they are:

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml
  AddOutputFilterByType DEFLATE application/json

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

Does anyone has a clue where my mistake is? Thanks!

1

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.

  • Thank's Andrew. I'll give it a try. And accept your answer if it works! – ChrisR34 Jun 12 '18 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.